This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Tag library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Tag library" Watch "Tag library" New topic
Author

Tag library

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi!
I try do a tag library followind step by step one example but allways throw :
org.apache.jasper.JasperException: No se puede abrir la libreria de tags /WEB-INF/random-taglib.tld : Parse Error in the tag library descriptor: com.sun.xml.parser/P-067
What signification have "Parse Error"?Can somebody help me?
Thank you in advance.
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Jordi,

(to non-spanish speakers:
"No se puede abrir la libreria de tags" means tag library could not be opened.
)
Its dificult to make a remote diagnostic, but maybe tomcat cannot find the random-taglib.tld where it expects it.
Please post your web.xml and your random-taglib.tld file.
Parse error means that there are problems in the parsing process.
To parse is the opposite of toString() method.
In toString() you convert some data to a String. Parsing is a process where you extract some data out of a String (in this case its xml-parsing). The xml - parser tries to extract some information out of the tld file (which is a sort of xml file).
Axel
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi!
web.xml --> \webapps\ROOT\WEB-INF
random-taglib.tld --> \webapps\ROOT\WEB-INF
RandomTag.java --> \webapps\ROOT\WEB-INF\classes\madhav\tags
RandomTag.class --> \webapps\ROOT\WEB-INF\classes
RandomNumExample.jsp --> \webapps\ROOT\jsp-intro
web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<taglib>
<taglib-uri>/random-taglib.tld</taglib-uri>
<taglib-location>/WEB-INF/random-taglib.tld</taglib-location>
</taglib>
</web-app>
random-taglib.tld :
//random-taglib.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">
<!-- a tag library descriptor -->
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>msajsp-tags</short-name>
<tag>
<name>random</name>
<tag-class>madhav.tags.RandomTag</tag-class>
<body-content>empty</body-content>
<description>Outputs a random 50-digit prime.</description>
</tag>
</taglib>
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
And did you copy the .class files in the proper folders?
.tld file to /WEB-INF/ folder.
RandomTag.class to /WEB-INF/classes/madhav/tags/ folder.
Also, please tell us your taglib directive declared in your JSP where you are accessing it?
I don't see anything wrong in the content of the web.xml or the .tld file.
Its either the placement of files in the folders or your JSP declaration....
- satya


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The .jsp file:
<HTML>
<HEAD>
<TITLE>Random Number Generator Tag</TITLE>
<%@ taglib uri="/WEB-INF/random-taglib.tld" prefix="generator" %>
</HEAD>
<BODY>
Hello..................1.2 JSP SPEC<BR>
Example of a random number generator tag adapted
from More Servlets and JSP.<BR>
<!-- H1><generator:random /></H1 -->
<generator:random />
<% Double valueD = (Double)pageContext.getAttribute("value");
String value = "" + valueD.doubleValue();
%>
<BR>
Printing the value set by the random tag...= <%= value %><BR>
The end!!!
</BODY>
</HTML>
I am working only with jdk 1.3, tomcat 3.1 and JBuilder 6, I`m not working with j2ee because I don�t know how integrate in the JBuilder. Can this be a problem??
Thank you in advance.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
tomcat 3.1
Positively, this is a problem. It doesn't understand the tags defined for the Web App DTD 2.2 version.
http://java.sun.com/j2ee/dtds/web-app_2.2.dtd
in your DTD file.
Tomcat 3.1 is for Servlets 2.2 and JSP 1.1. The tag sub elements you used in the DTD are based on JSP 1.2 Spec and you need Tomcat 4.?? for this.
See the Links page on where to get Tomcat 4.??
Good luck.
- satya
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
In your web.xml you have
<taglib-uri>/random-taglib.tld</taglib-uri>
<taglib-location>/WEB-INF/random-taglib.tld</taglib-location>

but in your jsp you have
<%@ taglib uri="/WEB-INF/random-taglib.tld" prefix="generator" %>
Shouldn't the uri attribute in your jsp directive match the uri in the web.xml file?
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Jason: It should. But it works that way, too. Here it references the tld directly without using the web.xml.
Its less flexible, because you have a hard-coded link from the code to the tld file, without using the web.xml for deployment-issues.
Axel
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Ah, danke Axel. Every example I've seen and done had matching uri's, didn't know you could bypass the web.xml.
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
better test it. :roll:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tag library
 
Similar Threads
jstl tag library
Custom Tags Example Errors
How to develope XML using JBuilder?
run custom tag
Struts iteration over String array