This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Tag help please

 
Bal Sharma
Ranch Hand
Posts: 273
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13044
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic