Tomcat

For details, see Section 2.4. Updated information on configuring Tomcat is available at http://www.coreservlets.com/.

Downloading the Software

http://jakarta.apache.org/tomcat/. Click on Binaries and choose the latest release version of either Tomcat 5 (servlets 2.4 and JSP 2.0) or Tomcat 4 (servlets 2.3 and JSP 1.2). Unzip into the location of your choice, hereafter referred to as install_dir .

Bookmarking the Servlet and JSP APIs

Tomcat bundles the documentation and links to it on the server homepage. Bookmark the version on disk so you can access it even when Tomcat is not running.

Setting Up Your Development Environment

Create a development directory. Develop code there; copy to the server's deployment directory for testing.

Set your CLASSPATH . Have it include install_dir /common/lib/servlet.jar , your main development directory, and " . " (the current working directory).

Make shortcuts to start and stop the server. In your development directory, make shortcuts to install_dir /bin/startup.bat and install_dir /bin/shutdown.bat . Double-click them to start and stop the server. Use startup.sh and shutdown.sh on Unix/Linux.

Using the Default Web Application

The main location is install_dir /webapps/ROOT . Create install_dir /webapps/ROOT/WEB-INF/classes if the classes directory does not already exist. You have to enable the ROOT context to use the default Web application (see the preceding section on configuring the server).

Packageless Servlets

Code: install_dir /webapps/ROOT/WEB-INF/classes

URL: http:// host /servlet/ ServletName

Packaged Servlets

Code: install_dir /webapps/ROOT/WEB-INF/classes/ packageName

URL: http:// host /servlet/ packageName.ServletName

Packaged Beans and Utility Classes

install_dir /webapps/ROOT/WEB-INF/classes/ packageName

JAR Files

install_dir /webapps/ROOT/WEB-INF/lib

HTML and JSP Pages (Not In Subdirectories)

Code Location: install_dir /webapps/ROOT

URL: http:// host/filename

HTML and JSP Pages (In Subdirectories)

Code Location: install_dir /webapps/ROOT/ directoryName

URL: http:// host/directoryName/filename

Using Custom Web Applications

Create a Web application directory in install_dir /webapps . The directory should have a WEB-INF subdirectory, a web.xml file in WEB-INF (copy the one from ROOT ), and a WEB-INF/classes subdirectory. Instead of a regular directory, you can also use a WAR file (JAR file with file extension renamed from .jar to .war ) with this structure. In the following, we use webappName to refer to the name of the directory (or the base name of the WAR file, minus . war ). See Section 2.11 for details.