Reputation: 3249
I am trying to deploy and run the Hello World application using IntelliJIDEA 14.1.4
on Tomcat 8.0.14(Tomcat Server -> Local
). The project was created using maven-archetype-webapp
and later imported
to the IDE by specifying path to pom.xml
.
Everything works fine as documented in the servlets
tag info, but when I remove the following line:
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
and add it in my include.jsp
, I encounter an:
org.apache.jasper.JasperException: /WEB-INF/jsp/hello.jsp (line: 18, column: 42) The attribute prefix [fn] does not correspond to any imported tag library
<%-- 'header' file that will be included in every JSP page ensuring the same definitions are included in all our JSPs. --%>
<%@ page session="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<c:redirect url="/WEB-INF/jsp/hello.jsp"/>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Application Home</title>
<style>.error {
color: red;
}
.success {
color: green;
}</style>
</head>
<body>
<form action="hello" method="post">
<h1>Hello</h1>
<p>
<label for="name">What's your name?</label>
<input id="name" name="name" value="${fn:escapeXml(param.name)}">
<span class="error">${messages.name}</span>
</p>
<p>
<label for="age">What's your age?</label>
<input id="age" name="age" value="${fn:escapeXml(param.age)}">
<span class="error">${messages.age}</span>
</p>
<p>
<input type="submit">
<span class="success">${messages.success}</span>
</p>
</form>
</body>
</html>
Is it a bad idea to add the line only once(include.jsp
) so that I can use it where required rather than adding it in every JSP or is the error cause because of something else which I am missing?
Upvotes: 1
Views: 2314
Reputation: 3249
Silly, as it may seem, I missed the include statement in hello.jsp
which was causing the exception. Posting the answer because I want to keep this information here for future reference.
Missing statement inside hello.jsp
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<!DOCTYPE html>
....
</body>
</html>
Upvotes: 2