SWE 432 Installation Instructions for Tomcat

2/11/2004


The ISE department provides a publically accessible web site that supports servlets and JSPs, and I expect most of you to use Hermes as your "target distribution computer". You can set up your own PC to support your servlets and JSPs at home. This will allow you to do most of your development and testing without having to go through GMU's computer systems. Please remember installing your servlets on Hermes for grading is different and will take some time.

The following installation instructions will help you get and install Tomcat on your PC. Tomcat is the same servlet container that runs on Hermes.

  1. Download and Install Java Development Kit
    1. Download Java 2 Platform, Standard Edition, v 1.4.2 (J2SE) from http://java.sun.com/j2se/1.4.2/download.html
      select "Download J2SE v 1.4.2_03 SDK "
    2. Install the JDK according to the instructions included with the release.
    3. Set the environment variable JAVA_HOME to the directory where you installed the JDK release.
      Start-> Setting-> Control Panel-> System-> Advanced-> Environment variables-> Go to system variable dialog-> Add new system variable (JAVA_HOME), variable value (drive:\yourjdkdirectory)
  2. Download Tomcat from: http://mirrors.mix5.com/apache/jakarta/tomcat-4/v4.1.29/bin/jakarta-tomcat-4.1.29.zip
  3. Unzip jakarta-tomcat-4.1.29.zip.
    Assuming you unzipped it on drive D, the path is D:\jakarta-tomcat-4.1.29
  4. Startup Tomcat
    Execute the following commands from a command (DOS) window:
    d:\jakarta-tomcat-4.1.29\bin\
    startup
    After startup, the default web applications included with Tomcat 4.0 will be available by browsing http://localhost:8080/
  5. Deploy Servlet
    1. Go to d:\jakarta-tomcat-4.1.29\webapps
      You might need to create a project directory under webapps. Assume you give your project name as swe432:
      Directory Contains
      \swe432 This is the root directory of the web application. All JSP and XHTML files are stored here.
      \swe432\WEB-INF\classes This directory is where servlet and utility classes are located.
      \swe432\WEB-INF This directory contains all resources related to the application that are not in the document root of the application. This is where your web application deployment descriptor is located. Note that the WEB-INF directory is not part of the public document. No files contained in this directory can be served directly to a client.
      \swe432\WEB-INF\lib This directory contains Java Archive files that the web application depends upon. For example, this is where you would place a JAR file that contained a JDBC driver.
    2. Copy your class files to the classes directory. Note that when you replace a class in the classes directory, the files do not get reloaded dynamically. You must restart the server (shutdown tomcat, restart it again).
  6. Create a default web.xml file under \swe432\WEB-INF\
    Here is a sample web.xml file:
      <?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>YourServletName (for example: hello)</servlet-name> 
        <servlet-class>YourServletClass (for example: HelloServlet.class)</servlet-class> 
       </servlet> 
       <servlet-mapping> 
        <servlet-name>YourServletName (for example: hello)</servlet-name> 
        <url-pattern>YourURLMapping (for example: hello)/hello</url-pattern> 
       </servlet-mapping> 
      </web-app>
       
  7. Access servlet by http://localhost:8080/ProjectRoot/ServletName/
    For example, http://localhost:8080/swe432/huang2Hello
  8. Shutdown tomcat
    Execute the following shell commands:
    d:\jakarta-tomcat-4.1.29\bin\
    shutdown

Back to assignments page Back to schedule page