Tomcat is a fully functional implementation of servlets and JavaServer Pages (JSP). It includes a Web server, so it can be used as a standalone test container for servlets and JSPs. Tomcat can also be specified as the handler for JSP and servlet requests received by popular Web servers such as the Apache Software Foundation's Apache HTTP server or Microsoft's Internet Information Services (IIS). Tomcat is also integrated into the Java 2 Enterprise Edition reference implementation from Sun Microsystems.
The most recent release of Tomcat at the time of printing (version 5.0.25) can be downloaded from
where there are several archive files. The complete Tomcat implementation is contained in the files that begin with the name jakarta-tomcat-5.0.25. Apache provides zip, exe, tar and compressed tar files.
Following the steps below to install Tomcat:
For Tomcat to work correctly, you must define environment variables JAVA_HOME and CATALINA_HOME. JAVA_HOME should point to the directory containing your Java installation (ours is C:Program FilesJavajdk1.5.0), and CATALINA_HOME should point to the directory that contains Tomcat (ours is C:jakarta-tomcat-5.0.25). To define these variables on Windows,
Error-Prevention Tip 26.1
On some platforms you may need to restart your computer for the new environment variables to take effect.
After setting the environment variables, you can start the Tomcat server. In a command prompt (or shell), change to the bin directory in jakarta-tomcat-5.0.25. In this directory are the files startup.bat, shutdown.bat, startup.sh and shutdown.sh, for starting and stopping the Tomcat server on Windows and UNIX/Linux/Mac OS X, respectively. To start the server, type
This launches the Tomcat server, which executes on TCP port 8080 to prevent conflicts with standard Web servers that typically execute on TCP port 80. [ Note: If port 8080 is already in use by another application, you can change the port number for Tomcat by modifying the file server.xml, which is located in the Tomcat installation directory's conf directory. To do so, edit line 92 of server.xml (which contains the text <Connector port="8080") and replace "8080" with the port number you want to use.] To verify that Tomcat is executing and can respond to requests, open your Web browser and enter the URL
[ Note : If you changed the port number, use the new port number you specified.] This should display the Tomcat documentation home page (Fig. 26.6). The host localhost indicates to the Web browser that it should request the home page from the Tomcat server on the local computer.
Figure 26.6. Tomcat documentation home page. Copyright © 2000-2004 The Apache Software Foundation (http://www.apache.org/). All rights reserved.
(This item is displayed on page 1247 in the print version)
Error-Prevention Tip 26.2
If the host name localhost does not work on your computer, substitute the IP address 127.0.0.1 instead.
To shut down the Tomcat server, issue the command
from the command prompt (or shell) that starts the Tomcat server.
Introduction to Computers, the Internet and the World Wide Web
Introduction to Java Applications
Introduction to Classes and Objects
Control Statements: Part I
Control Statements: Part 2
Methods: A Deeper Look
Classes and Objects: A Deeper Look
Object-Oriented Programming: Inheritance
Object-Oriented Programming: Polymorphism
GUI Components: Part 1
Graphics and Java 2D™
Files and Streams
Searching and Sorting
Introduction to Java Applets
Multimedia: Applets and Applications
GUI Components: Part 2
Accessing Databases with JDBC
JavaServer Pages (JSP)
Strings, Characters and Regular Expressions
Appendix A. Operator Precedence Chart
Appendix B. ASCII Character Set
Appendix C. Keywords and Reserved Words
Appendix D. Primitive Types
Appendix E. (On CD) Number Systems
Appendix F. (On CD) Unicode®
Appendix G. Using the Java API Documentation
Appendix H. (On CD) Creating Documentation with javadoc
Appendix I. (On CD) Bit Manipulation
Appendix J. (On CD) ATM Case Study Code
Appendix K. (On CD) Labeled break and continue Statements
Appendix L. (On CD) UML 2: Additional Diagram Types
Appendix M. (On CD) Design Patterns
Appendix N. Using the Debugger
Inside Back Cover