Hi ranchers,
As i faced many problems understanding & deploying Web Archive Files the last few days, here i m providing the step-by-step simple instructions of how to create a WAR file under Tomcat4.0.1+Windows 2000 server for all your benefits.
A web archive is a jar file that contains a whole web application structure including html,gif,
jsp,
servlet,javabean,jar etc various files. I created a context ashik4u in my root directory of
tomcat. Placed various jsp,html,fiels there. You may create this under a directory of your name as STEP-1. I'll refer the follwing figure as
chart-1.
ashik4u
=======
|
+ META-INF/
MANIFEST.MF
|
+ WEB-INF/ ---->|
web.xml+classes --->|
+wrTag/
HelloTag.class
|
+tlds
hello.tld
|
+images
--all gif files
CustomAction.jsp
--Other jsp files
design.html
--Other html files
Then compile HelloTag.java under wrTag package as STEP-2. Copy the compiled file according to chart-1. Source Code for HelloTag.java is taken & modified from Professional
Java Server Programming Volume I :
As STEP-3, Write down the tag library descriptor file & save according to chart-1.
As STEP-4, write down a simple JSP file named CustomAction.jsp like the follwoing and save it as chart-1.
<%@ taglib uri="/customAction" prefix="myExample" %>
<html>
<head>
<title>Testing Custom Actions</title>
</head>
<body bgcolor= #D5F6C7 background="/wrTag/WEB-INF/images/rolleyes.gif" text=blue>
This is a static content called template text!
<p />
<i>
<myExample:customAction></myExample:customAction>
</i>
This is a static content again!
</body>
</html>
Now STEP-5 would be to write down a deployment descriptor (web.xml file) for your web application. I assume u r not using Tomcat3 and rather Tomcat4. Otherwise you have to edit a little the code for web.xml that follows to be saved according to chart-1 ---
====================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<display-name>wrTag</display-name>
<description>Custom Tag Extension Example</description>
<session-config>
<session-timeout>0</session-timeout>
</session-config>
<!-- Tag Library Descriptor by Ashik-->
<taglib>
<taglib-uri>/customAction</taglib-uri>
<taglib-location>/WEB-INF/tlds/hello.tld</taglib-location>
</taglib>
</web-app>
=====================================================================
Write down a manifest file named MANIFEST.MF under META-INF. But i m still

whether this manifest file must have the entry for the HellTag class or not. The code goes ---
Manifest_Version: 1.0
Name: ..\CustomAction.jsp
Name: ..\WEB-INF\tlds\hello.tld
Name: ..\WEB-INF\web.xml
Name: ..\WEB-INF\classes\wrTag\HelloTag.class
Now STEP-7 would be make a war file thru jar command going to ashik4u directory in DOS prompt. The command is :
jar -cvf custom.war META-INF/MANIFEST.MF WEB-INF/classes/wrTag/HelloTag.class WEB-INF/images/*.gif *.html *.jsp At this stage you'll find a war file named custom.war which we desired so much.

As STEP-8 copy this file to the lib directory of your tomcat installation directory.
STEP-9 is to restart Tomcat to recognize this new custom.war and its directory structure. If catalina reports error during startup, find out the error, edit in appropriate file and then repeat STEP-7 TO STEP-9.
STEP-10 just accessing your newly created war in one of two ways :
(A) Write down & hit in your browser "http:localhost:8080/wrTag/CustomAction.jsp"
(B) Write down another html or jsp page and give the above addess as a href/html link to access.
That's all and now i m waiting for suggessions & comments from u. Any better and alternate ideas r most welcome! Without creating the war file i wanna know how can i access the custom tags in my jsp file.