wood burning stoves 2.0*
The moose likes Servlets and the fly likes Tag library.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tag library.." Watch "Tag library.." New topic
Author

Tag library..

Vimala Shirur
Greenhorn

Joined: Jan 12, 2001
Posts: 12
My tomcat server can't load my .class file. I get a JasperException saying unable to load com.j2ee.ExampleTag. I have placed this file where other classes are stored (C:\TOMCAT\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\) Can anybody help me to figure this out.
Here are my files
mytag-taglib.tld 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>mytag</shortname>
<uri></uri>
<info>
A simple tab library for the examples
</info>
<tag>
<name>example</name>
<tagclass>com.j2ee.ExampleTag</tagclass>
<info> Display JSP sources </info>
</tag>
</taglib>
ExampleTag class
----------------
package com.j2ee;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class ExampleTag extends TagSupport
{
public int doStartTag()
{
try
{
JspWriter out = pageContext.getOut();
out.println("My first Tag Example");
}
catch(IOException e)
{
System.out.println("error in ExampleTag: "+ e);
}
return(SKIP_BODY);
}

}
My jsp file
-----------
<HTML>
<HEAD>
<%@ taglib uri="mytag-taglib.tld" prefix="mytag" %>
<TITLE><mytag:example /></TITLE>
</HEAD>
<BODY>
<H1><mytag:example /></H1>
<mytag:example />
</BODY>
</HTML>

Thanks,


William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Did you modify the web.xml file to show that this taglib is used in the context? Here is an example:
<taglib>
<taglib-uri>JSPbook/taglib</taglib-uri>
<taglib-location>
/WEB-INF/jsp/JSPbook-taglib.tld
</taglib-location>
</taglib>
The other thing to double-check is that the directory structure from WEB-INF/classes exactly matches your package structure.

------------------
author of:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tag library..
 
Similar Threads
JSP Custom Tags -- Could Not Parse Deployment Descriptor
Mr. Simon Brown, Could You Help With This Custome Tag Problem?
Package javax.servlet.jsp.tagext not found .
Custom Tag Compilation
Can anybody help me to fix jsp Tag Libraray descriptor file maping