Installing Tomcat
- Download the zip file from http://jakarta.apache.org/ (or get it
from the cd supplied in class)
- Get the current version (5.0.9 beta at time of writing)
- Unzip it to a directory (ex. D:\, or /users/mwright)
The top level directory for Tomcat is jakarta-tomcat-4.0.1
This directory is known as Tomcat root or Tomcat home
It will be referred to as "tomcat_home"
Subdirectories in "tomcat_home":
- bin - scripts to startup and shutdown Tomcat as well as the
bootstrap code to run Tomcat itself (bootstrap.jar)
- common - contents of classes (.class files), endorsed, and
lib (.jar files) are all visible to Tomcat and webapps
- conf - configuration files
- logs - log files
- server - classes, libraries, and the server and
manager webapps for Tomcat itself
- shared - shared libraries and classes for the container, but not
needed by Tomcat internal classes. This is where you place classes you
want to share across all webapps
- webapps - user web applications
- work - scratch directory for Tomcat
Now, it's probably worth discussing how Tomcat handles classloading.
You will need to understand this a bit more as you develop more
sophisticated applications. Tomcat loads creates a set of class
loaders when it is started, with parent-child relationships.
Bootstrap
|
System
|
Common
/ \
Catalina Shared
/ \
Webapp1 Webapp2 ...
- Boostrap is just the essentials that Tomcat uses and what the
JVM provides
- System would normally be your own CLASSPATH variable, but the
Tomcat scripts ignore this, and set this to bootstrap.jar (part of
Tomcat), and tools.jar (which has javac needed for JSP compilation,
which we'll get to later)
- Common - in the common directory. These are used for both
Tomcat internals and webapps
- Catalina - invisible to webapps, meant for Tomcat
- Shared - shared by Tomcat and webapps
- Webapp - a classloader for each webapp, so they can be distinct
Read the documentation at
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/index.html
Set some environment variables
- JAVA_HOME - set to your Java installation
- CATALINA_HOME - set to your Tomcat installation
Only JAVA_HOME is really needed, but the second ensures you point to the
right instance of Tomcat if you have more than one installed.
On Windows:
set JAVA_HOME=c:\j2sdk1.4.2
set CATALINA_HOME=c:\jakarta-tomcat-5.0.9
On Linux (bash)
export JAVA_HOME=/usr/local/j2sdk1.4.2
export CATALINA_HOME=/usr/local/jakarta-tomcat-5.0.9


