wood burning stoves 2.0*
The moose likes Servlets and the fly likes Unable to open tld : Error 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 » Java » Servlets
Bookmark "Unable to open tld : Error" Watch "Unable to open tld : Error" New topic
Author

Unable to open tld : Error

Sharnag Thorat
Greenhorn

Joined: Nov 22, 2000
Posts: 2
following is the sample of tld

<?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-jsptaglib_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>mut</shortname>
<uri> </uri>
<info>
RSExplorer java server pages
</info>
<tag>
<name>HelloWorldTag</name>
<tagclass>HelloWorldTag</tagclass>
<bodycontent>empty</bodycontent>
</tag>

</taglib>
jsp page using tag lib is
<html>
<head>taglib test</head>
<body>
<%@taglib uri="taglib.tld" prefix="ttag" %>
<ttag:HelloWorldTag>
</ttag:HelloWorldTag>
</body>
<html>
i have placed the jsp page and taglib.tld in same director
java code for the handler class is
import java.io.IOException;
import java.io.PrintStream;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;
public class HelloWorldTag extends TagSupport{
public int doStartTag() throws JspException{
try{
JspWriter out = pageContext.getOut();
out.print("Hello Old Boy");
out.print("It seems that you r on right track");
}catch(IOException e){ }

return SKIP_BODY;

}

}
now when i try to access the page i am getting following error:
org.apache.jasper.JasperException: Unable to open taglibrary taglib.tld : Unable to open the tag library descriptor: Stream closed.
can anybody help please
Brian Nice
Ranch Hand

Joined: Nov 02, 2000
Posts: 195
I think the .tld file should be in a different directory than your JSP file. The JSP file is usually at your web application's root, while the .tld file should be in the web-inf directory under that root. Your tag class whould then go in the web-inf\classes directory. Try that and see if that works.
Brian
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Brian thanks for reply.Please have look at following part
from jsp1.1 spec
Case C - <%@ taglib uri="NOROOT_REL_URI" prefix="foo" %>
where NOROOT_REL_URI is a relative URI that does not start with "/"
1 Look in the processed web.xml for a taglib entry whose TAGLIB_URI is
NOROOT_REL_URI.
2a If found, the TABLIB_LOCATION for the taglib entry is the value to assign to
TLD_URI.
2b If no such entry is found, resolve NOROOT_REL_URI relative to the current JSP
page where the directive appears. Let ROOT_REL_URI be the resolved value (this
is a relative URI specification that starts with "/" - by definition-). ROOT_REL_URI
is the value to assign to TLD_URI.
3 Use TLD_URI to locate the TLD (see issue 9). If the TLD cannot be located a
translation error is raised.
Issue 9 �
Taglib directive: Locating TLDs
This is the second part of how to interpret the uri attribute of a taglib directive.
Once the TLD_URI has been resolved according to the resolution of Issue 8, how
to locate the TLD.
Resolution
There are two cases. In both cases the TLD_URI is to be interpreted relative to
the root of the Web Application.
In the first case the TLD_URI refers to a TLD file directly..
In the second case, the TLD_URI refers to a JAR file. If so, that JAR file should
have a TLD at location META-INF/taglib.tld.
so when i dont specify entry in web.xml and when .tld is kept
in same directory as jsp is then it should work as the root of
application is the directory in which jsp is.
But it doesnot happen that way.
help out guys...
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Please note that The Java Ranch has a naming policy, described here and "tsharang" is not a valid name. Presumably you are the same person as "Sharnag Thorat". If so, please use the full name instead of the one word abbreviation.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
P SOLAIAPPAN
Ranch Hand

Joined: Oct 20, 2000
Posts: 68
Hi,
you can keep your tld file where ever you feel like keeping it by entering in web.xml file. The default location is where your jsp programs is kept.
I have corrected the errors in the above program run the following
"taglib.tld"
<?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>mut</shortname>
<uri> </uri>
<info>
RSExplorer java server pages
</info>
<tag>
<name>HelloWorldTag</name>
<tagclass>HelloWorldTag</tagclass>

</tag>
</taglib>
The error in yours is
(a)
"Microsystems, Inc./DTD " but should be "Microsystems, Inc.//DTD" (i.e //)
(b) remove this item
<bodycontent>empty</bodycontent>
When you are using <body> of HTML document you can not use "Empty" .

"test.jsp"
<html>
<head>taglib test</head>
<body>
<%@taglib uri="taglib.tld" prefix="mut" %>
<mut:HelloWorldTag>
</mut:HelloWorldTag>
</body>
<html>
You have to use "mut" as prefix as defined in your taglib.tld
Remainning are ok.
Run your program ,it will be ok now (I verified it)
solaiappan


[This message has been edited by P SOLAIAPPAN (edited December 07, 2000).]
Sharang Thorat
Greenhorn

Joined: Dec 07, 2000
Posts: 21
Thanks solaiappan. it works now.
sharang
 
Don't get me started about those stupid light bulbs.
 
subject: Unable to open tld : Error
 
Similar Threads
jsp custom tag issues
Cannot resolve symbol
Custom Tag Compilation
Custom Tag NOT Compiling
CUSTOM TAG NOT WORKING