how to write web.xml file for customtags..
Hi developers,
I am new to customtags. Could you please help in creation of custom tags. Previously i asked so many times this question. But what to do, I have no help. That's why i am requesting you. My problem is i can create taghandler file,write tld file well. My problem comes at web.xml(deployment descripter). I am try to fail.
This is my sample tag examples files
StartTag.java file
package com.pro;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
publicclass StartTagextends TagSupport
{
publicint doStartTag()
{
try
{
JspWriter out = pageContext.getOut();
out.println("This is my first tag");
}catch(Exception e){e.toString();}
return (SKIP_BODY);
}
publicint doEndTag()
{
return (SKIP_PAGE);
}
}
put it into D:\Program Files\Apache Group\Tomcat 4.1\webapps\custom\WEB-INF\classes\com\pro\StartTag.class
This is my myfirsttag.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>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>custom</shortname>
<uri>/custom</uri>
<tag>
<name>starttag</name>
<tagclass>com.pro.StartTag</tagclass>
</tag>
</taglib>
put into D:\Program Files\Apache Group\Tomcat 4.1\webapps\custom\WEB-INF\lib\myfirsttag.tld
This is my web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>StartTag</servlet-name>
<servlet-class>com.pro.StartTag</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>StartTag</servlet-name>
<url-pattern>/servlet/com.pro.StartTag</url-pattern>
</servlet-mapping>
<!-- <taglib>
<taglib-uri>/custom</taglib-uri>
<taglib-location>/WEB-INF/lib/taglib.tld </taglib-location>
</taglib>-->
</web-app>
put into D:\Program Files\Apache Group\Tomcat 4.1\webapps\custom\WEB-INF\web.xml
This is my start.jsp file
<html>
<head><title>firsttag</title></head>
<body>
<%@ taglib uri="/custom" prefix="custom" %>
<h1><custom:starttag></custom:starttag></h1>
</body>
</html>
Every thing working ok without <taglib></taglib> in web.xml. If i remove comments it dosen't work well. Please guide me where i am doing wrong.
Thanking you
with regards
sure...:)-

