(Draft)
Abdul Habra, 10.16.2001
This document describes how to deploy Servlets and JSPs to Tomcat 3.2.3 on an
MS-Windows system.
Let the JDK be installed in the directory C:\Java\jdk1.3.0\
Set the following environment variable (using System Properties/Environment)
JAVA_HOME=C:\Java\jdk1.3.0\
Let Tomcat be installed in the directory: C:\Java\Jakarta\Tomcat\jakarta-tomcat-3.2.3\
Let's call this directory TH (for Tomcat Home)
Set the following environment variable (using System Properties/Environment)
TOMCAT_HOME=C:\Java\Jakarta\Tomcat\jakarta-tomcat-3.2.3\
To start Tomcat, go to TH/bin and at the command line run startup.
To stop Tomcat, in the same command window, run shutdown.
To verify that Tomcat is running, in a browser window go to http://localhost:8080/index.html which will show you a page with Tomcat info and examples.
TH has a directory named webapps, this is the default directory for your web applications. Put your .war files in the webapps directory.
This section will explain how to deploy an application that consists of Servlet classes.
Assume that we have:
To test the Servlet, go to this URL in the browser http://localhost:8080/ap1/servlet/pack1.C1
This will run your Servlet. Notice that the use of the word servlet in the URL's path does not correspond to an actual directory.
If the Servlet class did not have a package we would have copied it in TH\webapps\ap1\WEB-INF\classes\ (no pack1 directory), and would run it with the URL http://localhost:8080/ap1/servlet/C1
<Context path="/jap1"
docBase="c:/jap1"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
This tells the server to map requests that start with /jap1 (after the server name and port number) to the directory c:/jap1
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name> localAlias </servlet-name>
<servlet-class> pack1.C1 </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> localAlias </servlet-name>
<url-pattern> /MyServet </url-pattern>
</servlet-mapping>
</web-app>
This tells the server to map requests for /MyServlet to pack1.C1 Servlet class.
Note that the value of the <servlet-name> element, which is localAlias, is arbitrary and is not visible outside the web.xml file.
To test the Servlet, go to this URL in the browser: http://localhost:8080/jap1/MyServlet
This will run your Servlet.
In addition to Tomcat's documentation, the following links can be helpful:
| Page Last Updated 2001.10.16 |
|