Setting Up the Apache Tomcat Server

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

apache.towardex.com/jakarta/tomcat-5/v5.0.25/bin/

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:

  1. Download jakarta-tomcat-5.0.25.zip (or the version appropriate for your system) to your hard disk.
  2. Use a file extractor tool (such as WinZip, available at www.winzip.com) to extract the content of jakarta-tomcat-5.0.25.zip to the C: drive. This will create a directory named jakarta-tomcat-5.0.25.

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,

  1. Right click on the My Computer icon on your desktop and select Properties from the menu. The System Properties dialog appears.
  2. Select the Advanced tab at the top of the System Properties dialog. Click the Environment Variables button to display the Environment Variables dialog.
  3. Click the New button under the User variables box. This will cause the Edit User Variable dialog to appear.
  4. Enter JAVA_HOME for Variable name and C:Program FilesJavajdk1.5.0 for Variable value. Click the OK button to complete the setting of the JAVA_HOME variable. This will return to the Environment Variables dialog.
  5. Click the New button under the User variables box. This will cause the Edit User Variable dialog to appear.
  6. Enter CATALINA_HOME for Variable name and C:jakarta-tomcat-5.0.25 for Variable value. Click the OK button to complete the setting of the CATALINA_HOME variable. This will return to the Environment Variables dialog.
  7. Click the OK buttons to close the Environment Variables and System Properties dialogs.

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

 startup

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

 http://localhost:8080/

[ 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

 shutdown

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

Arrays

Classes and Objects: A Deeper Look

Object-Oriented Programming: Inheritance

Object-Oriented Programming: Polymorphism

GUI Components: Part 1

Graphics and Java 2D™

Exception Handling

Files and Streams

Recursion

Searching and Sorting

Data Structures

Generics

Collections

Introduction to Java Applets

Multimedia: Applets and Applications

GUI Components: Part 2

Multithreading

Networking

Accessing Databases with JDBC

Servlets

JavaServer Pages (JSP)

Formatted Output

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



Java(c) How to Program
Java How to Program (6th Edition) (How to Program (Deitel))
ISBN: 0131483986
EAN: 2147483647
Year: 2003
Pages: 615

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net