Tomcat Setup and Configuration for CS320

This document describes a step-by-step procedure to install a Tomcat server with additional packages under Windows 2000.


Before installing Tomcat, make sure you already have J2SE 1.4 or above installed. If not, download J2SE 1.4.2 and install it first. In the rest of the document, I will assume that J2SE is installed under the directory d:\j2sdk.

[Download and Installation]

Download Tomcat 5.0.28 binary release from the Apache Jakarta Project, and unzip the files to a local directory, e.g. d:\jakarta-tomcat-5.0.28.

Note that there are several Tomcat versions available for download. Version 5.0.28 is the current stable version that supports the latest Servlet and JSP specifications, and is the version that we are going to use in the class. Also note that for installation on Windows, you may choose to download either a ZIP file or an EXE file. If you want to setup Tomcat as a service on Windows 2000/XP, you should download the EXE file; otherwise you should download the ZIP file because a) installation from the ZIP file does not require administrator privilege, and b) in a development environment, you may often want to restart your Tomcat server, and it is easier to start up, shut down, and restart the server as a regular process than as a service.

[Environment Variables]

Set two environment variables: JAVA_HOME and CATALINA_HOME.

JAVA_HOME should be set to the directory where J2SE is installed, e.g d:\j2sdk, and CATALINA_HOME should be set to the directory where Tomcat is installed, for example, d:\jakarta-tomcat-5.0.28. To check whether these environment variables are set properly, open a Command Prompt and do:
> echo %JAVA_HOME%
[Understand Tomcat Directory Structure]

Some key Tomcat directories, all relative to %CATALINA_HOME%:
[1st Test Run]

Start Tomcat server by running the startup.bat script. Open a browser window and go to URL http://localhost:8080, and the "Congratulation" page should appear.

Shutdown Tomcat server by running the shutdown.bat script.

[Edit Configuration Files]

Open web.xml and search for "invoker". Uncomment the <servlet> and <servlet-mapping> elements for the invoker servlet.

Open tomcat-users.xml, and add an admin user and an manager user, e.g.
  <user name="tomadmin" password="xyz" roles="admin" />
  <user name="cysun" manager="abcd" roles="manager" />
The user names and passwords are arbitary.


Download context.xml  to the %CATALINA_HOME%\conf\Catalina\localhost directory. Rename the file to the login name assigned to you on the CS server, e.g. cs320stu31.xml, and edit the file to replace "username" with the your actual login name on the CS server. Again, assume your login name is cs320stu31, your cs320stu31.xml should look like the following:
A context file describes the URL path, the file location, and the runtime environments for a web application. In particular,
[Understand Web Application Directory Structure]

Like the Tomcat server itself, each web application has its own directory structure, rooted at docBase specified in the context file. Assume your docBase is set to cs320stu31 as described in the last section, you need to create the following subdirectories under %CATALINA_HOME%\webapps:
[Additonal Packages]

Download the MySQL JDBC Driver, MySQL Connector/J 3.0  from, and extract mysql-connector-java-3.0.15-ga-bin.jar to %CATALINA_HOME%\shared\lib.

Download JSP Standard Tag Library (JSTL) from the Apache Jarkata Project. There are many taglibs available, and the one you should get is Once you download the file, extract jstl.jar and standard.jar to %CATALINA_HOME%\shared\lib.

[2nd Test Run]

Download HelloJSTL.jsp to your docBase directory, and use a browser to access it at http://localhost:8080/username/HelloJSTL.jsp, and you should see the message "Hello World in JSTL".

THE END (or the beginning of a fun class)