Deploying Servlets and JSPs on Tomcat - (Draft)Abdul Habra, 10.16.2001 Table Of Contents1. TOMCAT INSTALLATION1.1. LOCATION 1.1.1. JDK Location 1.1.2. Tomcat Location 1.2. START AND STOP 1.3. DIRECTORIES 2. DEPLOYING APPLICATIONS OF SERVLETS CLASSES 2.1. CREATING CLASSES 2.2. DEPLOYING IN DEFAULT DIRECTORY 2.2.1. Running 2.2.2. Note 2.3. DEPLOYING IN ANY DIRECTORY 2.3.1. Preparing Directories 2.3.2. Modifying server.xml 2.3.3. Modifying web.xml 2.3.4. Running 3. REFERENCES This document describes how to deploy Servlets and JSPs to Tomcat 3.2.3 on an MS-Windows system. 1. Tomcat Installation1.1. Location1.1.1. JDK LocationLet 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\ 1.1.2. Tomcat Location 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\ 1.2. Start and StopTo 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. 1.3. DirectoriesTH has a directory named webapps, this is the default directory for your web applications. Put your .war files in the webapps directory.2. Deploying Applications Of Servlets ClassesThis section will explain how to deploy an application that consists of Servlet classes.2.1. Creating ClassesAssume that we have:
2.2. Deploying In Default Directory
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. 2.2.2. Note 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 2.3. Deploying In Any Directory2.3.1. Preparing Directories
2.3.2. Modifying server.xml
2.3.3. Modifying web.xml
Note that the value of the <servlet-name> element, which is localAlias, is arbitrary and is not visible outside the web.xml file. 2.3.4. Running To test the Servlet, go to this URL in the browser: http://localhost:8080/jap1/MyServlet This will run your Servlet. 3. ReferencesIn addition to Tomcat's documentation, the following links can be helpful:
|