Section 1.2. Installing Tomcat


1.2. Installing Tomcat

Start by downloading and installing the latest released version of Tomcat (browse to http://jakarta.apache.org/tomcat/ and select the Current Releases link under the Downloads section). If you have never used Tomcat, you're in for a pleasant surprise. Tomcat is a great servlet engine that is used as the reference for the Java Servlet and JavaServer Pages technologies.

Tomcat is free, and Tomcat is mature. If you get a released production version, you will find that it is as stable as any production-version commercial application server. The Tomcat project also has good documentation; take advantage of it. If you're new to Tomcat, another good resource is Jason Brittain and Ian Darwin's Tomcat: The Definitive Guide (O'Reilly).

1.2.1. A Minimalist Guide to Setting Up Tomcat

For Linux/Unix, download the tar.gz file and install it by running tar -zxvf in the directory where you want Tomcat to reside (e.g., /usr/local/tomcat). For Windows, Tomcat ships as a self-extracting executable: just download and run setup.exe to install it.

Once you've installed Tomcat, start it running on Linux or Unix with the following command:

 /<tomcat install directory>/bin/startup.sh 

On Windows, use the following command:

 \<tomcat install directory>\bin\startup.bat 

Then start up a browser and browse to http://localhost:8080 to see the Tomcat home page. From there you can run the example servlets to ensure that your installation is working correctly.

To shut down Tomcat, run the command shutdown.sh (Linux) or shutdown.bat (Windows) from your install directory.

1.2.2. Setting TOMCAT_HOME

All the examples in this book will be built and deployed with Ant. (If you're not familiar with Ant and the concept of build files, you might want to take some time to familiarize yourself with them now.) The build files will require the TOMCAT_HOME environment variable to be set properly, to ensure that when you deploy your applications, build.xml will copy everything you need into the webapps directory of the Tomcat server.

To check the value of TOMCAT_HOME on a Windows machine, type set from a command prompt. Along with the other environment variables, you should see:

 TOMCAT_HOME=c:\apps\Tomcat5.0 

TOMCAT_HOME should be set to the location where you installed Tomcat. If it is not, set TOMCAT_HOME using the environment variables setup screen (Start Control Panel System Properties Advanced Environment Variables). If you dont know how to do this, open Help from the Start menu and search for "environment variables."

On Linux, from a command prompt type the command set | grep TOMCAT. You should see something like this:

 TOMCAT_HOME=/usr/local/tomcat/Tomcat5.0 

Again, the value of TOMCAT_HOME should be the directory where you installed Tomcat. If it isn't, you need to set it correctly. Usually this requires adding an export command such as the following to a resource file like .bashrc:

 export TOMCAT_HOME=/usr/local/tomcat/Tomcat5.0 




Ajax on Java
Ajax on Java
ISBN: 0596101872
EAN: 2147483647
Year: 2007
Pages: 78

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