SWE 642 Installation Instructions for Tomcat

2/19/2009, update 9/29/2009


The Software Engineering group has cooperated with the IT&E Computing Resources group to provide 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.6
    1. The apps-swe642 server uses Java 6, therefore it is reccomended that you use that version. Download J2EE from http://java.sun.com/
    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)
    4. You may need to restart your computer.
  2. Hermes has Tomcat 5.5 installed, therefore it is a good idea to use the same version. Download Tomcat "Core" zip file from: http://tomcat.apache.org/download-55.cgi
  3. Unzip apache-tomcat-5.5.27.zip.
    Assuming you unzipped it on drive C, the path is C:\apache-tomcat-5.5.27
  4. Startup Tomcat
    Execute the following commands from a command (DOS) window:
    C:\apache-tomcat-5.5.27\bin\
    startup
    After startup, the default web applications included with Tomcat 5.5 will be available by browsing http://localhost:8080/
  5. Deploy Servlet
    1. Go to C:\apache-tomcat-5.5.27\webapps
      You might need to create a project directory under webapps. Assume you give your project name as swe642:
      Directory Contains
      \swe642 This is the root directory of the web application. All JSP and XHTML files are stored here.
      \swe642\WEB-INF\classes This directory is where servlet and utility classes are located.
      \swe642\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.
      \swe642\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 \swe642\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)</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/swe642/hello
  8. Shutdown tomcat
    Execute the following shell commands:
    C:\apache-tomcat-5.5.27\bin\
    shutdown

Back to schedule page


Thanks in part to Yanyan Zhu, Spring 2009