ContentsPreviousNextTomcat-Book Project

After you've had a look at Tomcat through the web browser, you will probably want to have a look at the file structure. Whilst we wont go into the details of Tomcat here, I'll give you a brief overview of what is contained in Tomcat, and what does what.

We've already seen that the bin directory contains the startup and shutdown scripts. These scripts delegate to the tomcat script, which also tries to guess TOMCAT_HOME and JAVA_HOME if they're not set. The main other file of interest in this directory is jspc or jspc.bat. This is used for precompiling JSPs. More about that in Chapter XXX.

The TOMCAT_HOME/conf directory is possibly the directory you will be most interested in. Tomcat's main configuration file is server.xml and resides in this directory. The other key files in this directory are:

The doc directory contains the standard documentation that comes with Tomcat. You should read through this documentation (as well as this book) if you have trouble with Tomcat before asking questions on mailing lists. Whilst people on the list will often answer questions that are answered in the doc directory, they are busy too, and by spending an hour reading all the documentation will prevent you asking a FAQ.

The lib directory contains the Tomcat application. The key files are webserver.jar, which is the web server itself (duh!), and servlet.jar, which contains the javax.servlet packages. The jasper.jar file contains the classes required for JSP compilation.

Also take note of jaxp.jar. As Tomcat (and servlets in general) use XML for configuration, a parser is required. The jaxp.jar file contains that parser. Note that you may need to remove this, and use a different parser if you use other applications that require a JAXP parser.

The src directory contains the src for Tomcat. This is the source to the webserver.jar and jasper.jar files in the lib directory.

The last directory that comes out of the distribution is the webapps directory. Any (valid) .war files placed in this directory prior to startup will be installed under their own context (based on filename) when Tomcat starts. Web Applications may also be placed in this directory unwarred, that is, in their normal directory structure (note that when Tomcat starts it by default will expand any .war files in this directory anyway).

After starting Tomcat you will notice two additional directories appear. The first is logs, which is pretty self explanatory. We will cover configuration of logging shortly. The second directory is more interesting: work. The work directory contains the generated source code, and compiled classes for JSPs. When a JSP is first requested, Tomcat (or more accurately Jasper) generates Java source code for the JSP, and then compiles it. Both the source code and the compiled class are stored in the work directory. Dont try changing the source code - it wont do anything. Thats not entirely true, just looking at the generated source code might give you a headache - it is not for the faint hearted, and definately not advisable for the novice.

ContentsPreviousNext