• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Internal Servlet Error with Custom tag

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm creating a very simple custom tag,and i'm getting this error:
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to open taglibrary csajsp1-taglib.tld : D:\jakarta-tomcat\webapps\examples\jsp\csajsp1-taglib.tld (The system cannot find the file specified)
Here is the tag handler file:
import javax.sevlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class example1 extends TagSupport
{
public int doStarTag()
{
try
{
JspWriter out = pageContext.getOut();
out.print("Good morning !!!");
}
catch(IOException e)
{
System.out.println("Error .....");
//System.out.println( e);
}
return (SKIP_BODY);
}

}
I'm putting that file in:
d:\jakarta-tomcat\webapps/root/web-inf/classes
Also here is the tag library file:
<?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">
<!-- a tag library descriptor -->
<taglib>
<!-- after this the default space is
"http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd"
-->
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>csajsp1</shortname>
<uri></uri>
<info>
A simple tab library for the examples
</info>
<tag>
<name>test</name>
<tagclass>example</tagclass>
<info> Display JSP sources </info>

</tag>
<!-- A simple Tag -->

</taglib>
I'm putting it in :
d:\jakarta-tomcat\webapps\examples\web-inf/jsp
here is the jsp file:
<HTML>
<HEAD>
<%@ taglib uri="csajsp1-taglib.tld" prefix="csajsp1" %>
<TITLE><csajsp1:test /></TITLE>
</HEAD>
</HTML>
i'm putting it in:
d:\jakarta-tomcat\webapps\examples\jsp
i will appreciate your help.
thanks alot
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the name of the .tld file, I beleive that you are using the book "core servlets & jsp" by Marty Hall. The error message you got means that the compiler had trouble to locate the .tld file:
1. First you should try to run some examples from the book. If they work then your configuration is correct.
2. The examples in the book work well if tomcat 3.0. If you use tomcat3.1, the chance is they will not work unless you modified the .tld file. Buy the book of Messr Duane Fields & Mark Kolb, it has a modified version of the .tld file suitable for tomcat3.1.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
thanks for your time.
yes the example int he book work fine.
that is mean the work with Tomcat3.1 is ok.
what do you think is the problem?
thanks.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the configuration of the .tld in the web.xml(examples context)?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Again and thanks for your time.
here is the file .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">
<!-- a tag library descriptor -->
<taglib>
<!-- after this the default space is
"http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd"
-->
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>csajsp1</shortname>
<uri></uri>
<info>
A simple tab library for the examples
</info>
<tag>
<name>test</name>
<tagclass>example</tagclass>
<info> Display JSP sources </info>

</tag>
<!-- A simple Tag -->

</taglib>
that is in :under examples\web-inf\jsp
i hope that will help you .
thanks
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A colleague pointed out this thread to me, so I wanted to point out that it is true that only Tomcat 3.1beta was out when the book went to print, and the format of the TLD file changed since then. Tomcat 3.1 final changed "urn" to "uri" (in conformance with the final JSP 1.1 spec) and stopped allowing "bodycontent" (in violation of the final JSP 1.1 spec).
Anyhow, an updated version of the TLD that works in Tomcat 3.1 final and on other compliant servers is now on the book's
source code archive at http://archive.coreservlets.com
Cheers-
- Marty
 
Cynthia Yao
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is wrong:
<%@ taglib uri="csajsp1-taglib.tld" prefix="csajsp1" %>
if the .jsp is under examples/, then
based on the location of the tld file. it should be:
<%@ taglib uri="\\WEB-INF\\jsp\\csajsp1-taglib.tld" prefix="csajsp1" %>
try it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic