Tomcat Installation Instructions

Required Skills

Instructions

  1. Locate the latest production version of Tomcat from http://jakarta.apache.org/site/binindex.html
  2. Go to the /bin subdirectory of the download directory.
  3. To minimize installation complexities, choose the "zip" file of the full (not "LE") version.
  4. Save the zip file (named something like jakarta-tomcat-4.0.4.zip) to your computer.
  5. Unzip the file into a directory of your choice (such as /usr/local or c:\). The program is contained in a subdirectory named something like jakarta-tomcat-4.0.4
  6. Open a command shell and change your directory to the Tomcat directory (such as /usr/local/jakarta-tomcat-4.0.4 or c:\jakarta-tomcat-4.0.4)
  7. Change to the bin subdirectory
  8. Type startup.sh (Unix) or startup.bat (Windows) followed by ENTER
  9. Point your web browser to http://localhost:8080. You should get a "Congratulations" page.
  10. To stop the Tomcat server, type shutdown.sh (Unix) or shutdown.bat (Windows) followed by ENTER. You should shut down and start up the server whenever you deploy an application. Make sure to shut down the server now.
  11. Change to the webapps subdirectory of the Tomcat installation directory.
  12. Create a subdirectory with the name of your web application (such as homework1). 
  13. Inside that subdirectory, create a subdirectory WEB-INF (all uppercase, with a hyphen, not an underscore). 
  14. Inside the WEB-INF directory, create yet another subdirectory classes. The full path to that directory should be something like /usr/local/jakarta-tomcat-4.0.4/webapps/homework1/WEB-INF/classes (Unix) or c:\jakarta-tomcat-4.0.4\webapps\homework1\WEB-INF\classes (Windows)
  15. Place a file web.xml into the WEB-INF directory that has the following contents:
    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!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>
    </web-app>
    You can copy it from the .../webapps/tomcat-docs/WEB-INF directory if you don't want to type in the file.
  16. For testing purposes, place a file test.jsp into your web application directory (such as ../webapps/homework1) with the contents
    <%= new java.util.Date() %>
  17. Start Tomcat again, as described previously
  18. Point your browser to http://localhost:8080/homework1/test.jsp. The current date and time should be displayed.
  19. Now you are ready to deploy your program. Place your JSP file(s) into the application directory. Place your class files into the WEB-INF/classes/bigjava subdirectory (see the note below).
  20. Remember to shut down the server when you are done.

IMPORTANT NOTE REGARDING PACKAGES

Tomcat 4 does not let you place beans into the default package. Instead, you need to place each bean class into a named package. Follow this procedure:
  1. Make a subdirectory WEB-INF/classes/bigjava to hold source and class files.
  2. Place the declaration
    package bigjava;
    as the first line of each source file
  3. Compile the files as follows:
  4. When referencing a bean in a JSP page, use the fully qualified class name, for example
    <jsp:useBean id="zone" class="bigjava.TimeZoneBean" scope="session"/>

To compile servlets, add .../common/lib/servlet.jar to your class path.