jQuery in Action, 3rd edition
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unable to open tld : Error" Watch "Unable to open tld : Error" New topic

Unable to open tld : Error

Sharnag Thorat

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

<?xml version="1.0" encoding="ISO-8859-1" ?>
"-//Sun Microsystems, Inc./DTD JSP Tag Library 1.1//EN"
<uri> </uri>
RSExplorer java server pages

jsp page using tag lib is
<head>taglib test</head>
<%@taglib uri="taglib.tld" prefix="ttag" %>
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{
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.
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
2a If found, the TABLIB_LOCATION for the taglib entry is the value to assign to
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.
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

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.

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

Joined: Oct 20, 2000
Posts: 68
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
<?xml version="1.0" encoding="ISO-8859-1" ?>
"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
<uri> </uri>
RSExplorer java server pages

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

<head>taglib test</head>
<%@taglib uri="taglib.tld" prefix="mut" %>
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)

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

Joined: Dec 07, 2000
Posts: 21
Thanks solaiappan. it works now.
I agree. Here's the link: http://aspose.com/file-tools
subject: Unable to open tld : Error
It's not a secret anymore!