You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by an...@csa.iisc.ernet.in on 2003/09/22 13:12:39 UTC

How to deploy the customtags in Apache Tomcat/4.1.24

----------------web.xml entry:---------------------------------------------
LOCATION:/home/ananth/tomcat1/jakarta-tomcat-4.1.24/webapps/examples/WEB-INF
---------------------------------------------------------------------------

<taglib>
                                                                                
<taglib-uri>
           http://144.16.67.72:8090/examples/WEB-INF/jsp
</taglib-uri>
                                                                                
<taglib-location>
         /WEB-INF/jsp/ mytaglib.tld
</taglib-location>

-----------tag library decriptor: mytaglib.tld--------------------------

LOC:/home/ananth/tomcat1/jakarta-tomcat-4.1.24/webapps/examples/WEB-INF/jsp/

----------------------------------------------------------------------- 

<?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>first</shortname>
   <uri></uri>
   <info>A simple tab library for the examples</info>
                                                                                
  <tag>
    <name>hello</name>
    <tagclass>tags.HelloTag</tagclass>
    <bodycontent>empty</bodycontent>
    <info>Say Hi</info>
  </tag>

</taglib>


-------------Java file: HelloTag.java---------------------------------------------

LOCATION::/home/ananth/tomcat1/jakarta-tomcat-4.1.24/webapps/examples/WEB-INF/classes/tags/
-----------------------------------------------------------------------------

package tags;
                                                                                
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
                                                                                
public class HelloTag extends TagSupport {
                                                                                
   public int doStartTag() throws JspException {
      try {
         pageContext.getOut().print("This is my first tag!");
      } catch (IOException ioe) {
 throw new JspException("Error: IOException while writing to client" + 
ioe.getMessage());
      }
      return SKIP_BODY;
   }
                                                                                
   public int doEndTag() throws JspException {
      return SKIP_PAGE;
   }
}

------------------JSP file: Hello.jsp-----------------------------------

<%@ taglib 
uri="http://144.16.67.72:8090/examples/WEB-INF/jsp/mytaglib.tld" 
prefix="first" %>
                                                                                                                                             
<HTML>
<HEAD><TITLE>Hello Tag</TITLE></HEAD>
                                                                                                                                             
<BODY bgcolor="#ffffcc">
                                                                                                                                             
<B>My first tag prints</B>:
                                                                                                                                             
<first:hello/>
                                                                                                                                             
</BODY>
</HTML>


------------------------------------------------------------------------


MY doubts:  

1) Whenever I make a new entry in the /WEB-INF/web.xml file  Iam not able 
to run tomcat.I can not execute any jsp's in /examples directory( 
CATALINA_HOME)

2) Should I create a new web.xml file for each web application or a new 
entryfor each webapp  in the existing /WEB-INF/web.xml will suffice

3) Is my deployment correct? ie JSP file,tld,class files are located in 
correct positions.


Iam not able to execute Hello.jsp.Please help on this 

If possible please send me a simple custom tag which is working. 



With regards
--------------------------------
Ananth R
Project Associate
Electronic Enterprise Laboratory
Computer Science and Automation
Indian Institute Of Science
Bangalore

---------------------------------
Phone:(off) 2932368-111
      (cdma)9844140340 

e-mail:ananthr@csa.iisc.ernet.in
       ananth_vadholasa@rediffmail.com


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org