Hello Everyone,
Please help me to create a customized tag in JSP. In
fact this example is from the book of "core servlets
and jsp".

web server is jakarta-tomcat 3.1
JSP 1.1

the tag handler class resides in
jakarta-tomcat/webapps/ROOT/WEB-INF/classes/coreservlets/tags/ExampleTag.class

the TLD file and .jsp resides in
jakarta-tomcat/webapps/csajsp-taglib.tld
jakarta-tomcat/webapps/SimpleExample.jsp

when I run http://localhost:8080/SimpleExample.jsp

the title is still <csajsp:example />. it didn't be
resolved to the customized tag. It looks like tomcat
can't recognize the customized tag. What's wrong here?

attachment the souce code:
=========================================
the handler java file ExampleTag.java
=========================================
package coreservlets.tags;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
/** Very simple JSP tag that just inserts a string
* ("Custom tag example...") into the output.
* The actual name of the tag is not defined here;
* that is given by the Tag Library Descriptor (TLD)
* file that is referenced by the taglib directive
* in the JSP file.
*/
public class ExampleTag extends TagSupport {
public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.print("Custom tag example " +
"(coreservlets.tags.ExampleTag)");
} catch(IOException ioe) {
System.out.println("Error in ExampleTag: " + ioe);
}
return(SKIP_BODY);
}
}

========================
csajsp-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">
<!-- 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>csajsp</shortname>
<urn></urn>
<info>
A tag library from Core Servlets and JavaServer Pages,
http://www.coreservlets.com/.
</info>
<tag>
<name>example</name>
<tagclass>coreservlets.tags.ExampleTag</tagclass>
<info>Simplest example: inserts one line of
output</info>
<bodycontent>EMPTY</bodycontent>
</tag>
<!-- Other tags defined later... -->
</taglib>
========================
SimpleExample.jsp
========================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
I am testing tag
<%@ taglib uri="csajsp-taglib.tld" prefix="csajsp" %>
<TITLE><csajsp:example /></TITLE>
<!--LINK REL=STYLESHEET HREF="JSP-Styles.css"
TYPE="text/css"-->
</HEAD>
<BODY>
This is testing tag
<H1><csajsp:example /></H1>
<csajsp:example />
</BODY>
</HTML>



Thanks a lot!
Jie


__________________________________________________
Do You Yahoo!?
Send instant messages with Yahoo! Messenger.
http://im.yahoo.com/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to