Testing Tomcat

The Tomcat installation directory contains a number of subdirectories. All of them are described in the README.txt file, but the most important ones are:

bin

Scripts for starting and stopping the Tomcat server.

conf

Tomcat configuration files.

webapps

Default l ocation for web applications served by Tomcat.

Two more subdirectories under the Tomcat home directory are created the first time you start the server:

logs

Server log files. If something doesn’t work as expected, look in the files in this directory for clues as to what’s wrong.

work

A directory for temporary files created by the JSP container and other files. This directory is where the servlets generated from JSP pages are stored.

To test the server, run the startup script as described in the platform-specific sections, and (assuming you’re running Tomcat on the same machine as the browser and that you’re using the default 8080 port for Tomcat) open a browser and enter this URL in the Location/Address field: http://localhost:8080/.

The Tomcat main page is shown in the browser, as in Figure 4-2, and you can now run all servlet and JSP examples bundled with Tomcat to ensure everything works.

The Tomcat main page

Figure 4-2. The Tomcat main page

If you’re trying this on a machine that sits behind a proxy, for instance on a corporate network, and instead of Tomcat’s main page you see an error message about not being able to connect to localhost, you need to adjust your proxy settings. For Netscape 6 and Mozilla, you find the proxy settings under Edit Preferences Advanced Proxies, and for Internet Explorer 5, you find them under Tools Internet Options Connections LAN Settings. Make sure that the proxy isn’t used for local addresses, such as localhost and 127.0.0.1.

When you’re done testing Tomcat, you stop the server like this:

C:\Jakarta\jakarta-tomcat-4.0.4\bin> shutdown

You should always stop the server like this, as opposed to killing the Tomcat process with Ctrl-C. Otherwise the applications don’t get a chance to close down gracefully, and when you start to connect to external resources, such as a database, various problems may occur.

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.