How to get taglibs working ? Currently getting a CompileException
843833Oct 2 2001 — edited Oct 10 2001I am having difficulties getting a custom tag library to work. I will explain what I've done so far and the errors I'm getting and hopefully somebody can enlighten me as to where I'm going wrong. I am using Tomcat version 3.2.1.
This is my first attempt at using taglibs so it's likely I am making a bonehead error, although I am following the instructions found in Hall's "Core Servlets and JSP" and the Tomcat development guide. Obviously I've done something wrong, but it's not obvious what that is.
I have a JSP which has the following lines of code in place to use my taglib:
<%@ taglib uri="/WEB-INF/errorMessages-taglib.tld"
prefix="errorMessages" %>
....
<errorMessages:message key="all" />
I have the taglib descriptor file under the web application's WEB-INF directory named errorMessages-taglib.tld and it looks like this:
-----------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>errorMessages</shortname>
<urn></urn>
<info>A tag library to display error messages</info>
<tag>
<name>message</name>
<tagclass>dataview.taghandler.ErrorMessagesTagHandler</tagclass>
<info>Outputs an error message corresponding to the key provided, if present</info>
<bodycontent>EMPTY</bodycontent>
<attribute>
<name>key</name>
<required>false</required>
</attribute>
</tag>
</taglib>
------------------
I have included a <taglib> entry in my web.xml which looks like:
<taglib>
<taglib-uri>errorMessages</taglib-uri>
<taglib-location>/WEB-INF/errorMessages-taglib.tld</taglib-location>
</taglib>
I am getting a Jasper compile exception when I attempt to access the page, telling me that it can't open the tld and that I need to terminate a "description" element, even though there is no "description" element in the tld (see above). Below are the exception messages:
Internal Servlet Error:
org.apache.jasper.compiler.CompileException:
/var/tomcat/webapps/dataview/Select.jsp(8,4) Unable to open taglibrary
/WEB-INF/errorMessages-taglib.tld : Parse Error in the tag library descriptor: Next character must be ">" terminating element "description".
at
org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java)
at
org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java)
at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java)
at org.apache.jasper.compiler.Parser.parse(Parser.java)
at org.apache.jasper.compiler.Parser.parse(Parser.java)
at org.apache.jasper.compiler.Parser.parse(Parser.java)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java)
..........
Can anybody see what it is that I'm doing wrong ? The exception message doesn't make any sense in the context (at least not to me). In any event I'm clueless as to how I might proceed, I've tried several different approaches (moving the tld to a different directory, using a different or no <taglib> entry in web.xml, etc.) but with no luck at all.
Thanks in advance for any suggestions or solutions.
-James