aspose file tools*
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Custom Tag help please " Watch "Custom Tag help please " New topic
Author

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"
"web-jsptaglib_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>bk</shortname>
<uri>/ok/jsp/ch14/tags/bk-taglib.tld</uri>
<info>First Custom tab</info>
<tag>
<name>kali</name>
<tagclass>bkservletpkg.tags.TagExample</tagclass>
<info>First Example</info>
<bodycontent>EMPTY</bodycontent>
</tag>
</taglib>
My JSP test driver is also at same location /webapps/ok/jsp/ch14/firstCustomTag.jsp as below;
<%@ taglib uri="bk-taglib.tld" prefix="bk" %>
<HTML>
<BODY>
<BR><BR><H1><CENTER><bk:kali></CENTER></H1>
<BR><BR><bk:kali/>
</BODY>
</HTML>
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
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Here is what I used:
<!DOCTYPE taglib
PUBLIC
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
Note that the dtd URI is absolute, not relative.
Bill
------------------
author of:
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Originally posted by William Brogden:
Here is what I used:
<!DOCTYPE taglib
PUBLIC
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
Note that the dtd URI is absolute, not relative.
Bill

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
SYSTEM
"file://my/path/to/local/copy/of/web-jsptaglibrary_1_1.dtd">
(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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom Tag help please