jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes Custom Tag help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Custom Tag help please " Watch "Custom Tag help please " New topic

Custom Tag help please

Bal Sharma
Ranch Hand

Joined: Sep 19, 2001
Posts: 273
Hello Everybody:
I wrote a small custom tag. It is not working,I do not know where is the problem? Could some one please give me right directions. Thanks in adavance.
My TagHandler Class �TagExample.java� is inside /WEB_INF/classes/bkservletpkg/tags/TagExample.java. It compiled and I saw class file there.
My Tag Library Discriptor is at /webapps/ok/jsp/ch14/ bk-taglib.tld as below;
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tablib
PUBLIC "-//Sun Microsystem, Inc.//DTD JSP Tag Library 1.1//EN"
<info>First Custom tab</info>
<info>First Example</info>
My JSP test driver is also at same location /webapps/ok/jsp/ch14/firstCustomTag.jsp as below;
<%@ taglib uri="bk-taglib.tld" prefix="bk" %>
I got following errors.
Error: 500
Location: /ok/jsp/ch14/firstCustomTag.jsp
Internal Servlet Error:
org.apache.jasper.compiler.CompileException: C:\tomcat3\webapps\ok\jsp\ch14\firstCustomTag.jsp(0,0) Unable to open taglibrary bk-taglib.tld : Parse Error in the tag library descriptor: Relative URI "web-jsptaglib_1_1.dtd"; can not be resolved without a document URI.
at org.apache.jasper.compiler.JspParseEventListener.handleDirective(JspParseEventListener.java:713)
at org.apache.jasper.compiler.DelegatingListener.handleDirective(DelegatingListener.java:116)
at org.apache.jasper.compiler.Parser$Directive.accept(Parser.java:215)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1077)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)
Error says unable to open �taglibrary bk-taglib.tld: Parse Error in the tag� can not be resolved without a document URI. I do not understand this message.
Please help me figure it out what am I doing wrong? Thanks again. BK
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13027
Here is what I used:
<!DOCTYPE taglib
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
Note that the dtd URI is absolute, not relative.
author of:
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Originally posted by William Brogden:
Here is what I used:
<!DOCTYPE taglib
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
Note that the dtd URI is absolute, not relative.

This should solve your problem, but please note that the problem may recur if the server your Tomcat instance is running on cannot reach the URL http://java.sun.com//... due to firewall setup, etc. An alternative is to instead use something like:
<!DOCTYPE taglib
(I hope you get the idea that this is an absolute file path).

Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Consider Paul's rocket mass heater.
subject: Custom Tag help please
It's not a secret anymore!