Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to open tld : Error

 
Sharnag Thorat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
P SOLAIAPPAN
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks solaiappan. it works now.
sharang
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic