Issue
I am creating a javaEE project with jsp and jstl as view module. When i'm trying to bulid it i get different Jasper Validation errors. Using maven and tomcat 9.0.21 as a server, all encodings set to utf-8
I've added jstl-1.2.jar to Project settings -> libraries and to war:exploded -> WEB-INF/lib. I also tried to remove dependencies and set different versions. If i remove both <%@ taglib %> fmt and c declarations, page is working (at least it doesn't cause server 500 error).
JSP:
{<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="${param.lang}">
<fmt:setLocale value="${param.lang}"/>
<fmt:bundle basename="message"/>
<head>
<title>Book list</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"/>
<link rel="stylesheet" href="WEB-INF/css/base.css"/>
</head>
<body>
<header>
<div class="row" id="lang">
<div class="col-2 justify-content-start" id="appName">Library app</div>
<div class="col-6"></div>
<div class="col-2 justify-content-end">
<p id="langLabel">Choose language:</p>
</div>
<div class="col-1 justify-content-center">
<a href="?lang=ua"><img src="../WEB-INF/images/uaFlag.jpg" alt="ua"/></a>
<a href="?lang=en"><img src="../WEB-INF/images/gbFlag.svg" alt="en"/></a>
</div>
<div class="col-1">
<form action="${pageContext.request.contextPath}/logout" id="logoutForm">
<button type="submit" id="logoutButton">Logout</button>
</form>
</div>
</div>
</header>
<div class="row" id="contentDiv">
<div class="content contentFirstBlock col-7 justify-content-center">
<div id="addbookFormBlock">
<form id="addbookForm">
<fmt:message key="input.addbook.bookName" var="bookName"/>
<fmt:message key="input.addbook.bookGenre" var="bookGenre"/>
<fmt:message key="input.addbook.bookIsbn" var="bookIsbn"/>
<fmt:message key="input.addbook.bookYearPublished" var="bookYearPublished"/>
<fmt:message key="input.addbook.submitAddBook" var="submitAddBook"/>
<label for="bookName">${bookName}</label><input type="text" id="bookName" name="bookName" autocomplete="off" required="required"/><br/>
<label for="bookGenre">${bookGenre}</label><input type="text" id="bookGenre" name="bookGenre" autocomplete="off" required="required"/><br/>
<label for="bookIsbn">${bookIsbn}</label><input type="text" id="bookIsbn" name="bookIsbn" autocomplete="off" required="required"/><br/>
<label for="bookYearPublished">${bookYearPublished}</label><input type="text" id="bookYearPublished" name="bookYearPublished" autocomplete="off" required="required"/><br/>
<input type="submit" id="submitAddButton" name="submitBook" value="${submitAddBook}"/>
</form>
</div>
</div>
<div class="content contentSecondBlock col-5">
<p>Sample</p>
<table>
<tr>
<td>Select</td>
<td>Author id</td>
<td>Author first name</td>
<td>Author last name</td>
</tr>
<c:forEach items="${authors}" var="author">
<tr>
<td><input type="checkbox" name="aths" value="${author.getAuthorId()}"/></td>
<td>${author.getAuthorId()}</td>
<td>${author.getAuthorFirstName()}</td>
<td>${author.getAuthorLastName()}</td>
</tr>
</c:forEach>
</table>
</div>
</div>
<footer>footer</footer>
</body>
</html>}
Dependencies
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/taglibs/standard -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.el/el-api -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- mySql connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>
The most recent set of errors:
Error:Jasper Validator: The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
Error:Jasper Validator: Unable to get JAR resource "http://java.sun.com/jsp/jstl/fmt" containing TLD: java.net.MalformedURLException: Path 'http:/java.sun.com/jsp/jstl/fmt' does not start with '/';
Error:Jasper Validator: Unable to find taglib "fmt" for URI: http://java.sun.com/jsp/jstl/fmt;
Error:Jasper Validator: org.apache.jasper.JasperException: java.lang.NullPointerException;
Errors i've gotten before:
Error:Jasper Validator: Validation error messages from TagLibraryValidator for c in /admin/addbook.jsp null: org.xml.sax.SAXParseException; lineNumber: 784; columnNumber: 8; An invalid XML character (Unicode: 0x0) was found in the CDATA section. Validation error messages from TagLibraryValidator for fmt in /admin/addbook.jsp null: org.xml.sax.SAXParseException; lineNumber: 784; columnNumber: 8; An invalid XML character (Unicode: 0x0) was found in the CDATA section.
Solution
Okay, i've solved this problem, maybe it will help someone.
Dependencies:
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>
</dependencies>
I just copied code from jsp to another empty jsp file and deleted the first one. After that (and modification of dependencies) validation passes succesfully. Also i removed all jars from WEB-INF/lib and added jstl-1.2.jar to the tomcat/lib folder (i don't know is it needed but if your code is still broken, you can try).
Answered By - Maksym Pidgornyi