Question

I want to write some jsp tag files for my application. I followed this article: http://www.techrepublic.com/article/an-introduction-to-jsp-20s-tag-files/

However, I'm stuck, when I open a jsp page that has this line:

<%@ taglib prefix="h" uri="/WEB-INF/tags"%>

I get an exception.

HTTP Status 500 - /test.jsp (line: 8, column: 41) File "/WEB-INF/tags" not found
org.apache.jasper.JasperException: /test.jsp (line: 8, column: 41) File "/WEB-INF/tags" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)

If I refresh the page, sometimes I got a different page:

HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.test_jsp
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.test_jsp

All I did was, in eclipse I created a folder called "tags" in WebContent/WEB-INF. I created a tag file, "email.tag" , with the following content:

<%@ tag language="java" pageEncoding="ISO-8859-1"%>
<%@ attribute name="email" required="true" %>
<%
    String emailOutput = "<a href=\"mailto:{$email}\">${email}</a>";
%>
<%=emailOutput %>

Eclipse autocomplete recognizes, and suggests this:

<h:email email=""></h:email>

I use Tomcat7. I tried to search for this error on google and here, but could not find an answer. What am I missing?

Was it helpful?

Solution

That's not how tag files must be used. The correct syntax is

<%@ taglib tagdir="/WEB-INF/tags" prefix="h" %>

See http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPTags5.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top