O'Reilly logo

Tomcat: The Definitive Guide, 2nd Edition by Ian F. Darwin, Jason Brittain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Configuration

Once you have Tomcat running, you need to customize its configuration. For example, you may want to support virtual hosting. Tomcat also features realms, which are lists of users authorized to implement specific sections of your web site. Using realms, we show you how to set up an example JDBC domain to talk to a relational database. We also show you many of the other configuration changes you can make.

Configuring Tomcat is mainly done by editing files and restarting Tomcat. The following are the main configuration files provided with Tomcat that reside in the $CATALINA_HOME/conf directory:

server.xml

The main Tomcat configuration file.

web.xml

A servlet specification standard format configuration file for servlets and other settings that are global to all web applications.

tomcat-users.xml

The default list of roles, users, and passwords used by Tomcat's UserDatabaseRealm for authentication.

catalina.policy

The Java security policy file for Tomcat.

context.xml

The default context settings that are applied to all deployed contexts of all hosts in this installation of Tomcat.

The first three files are well-formed XML documents and are parsed by Tomcat at startup; the web.xml file is also validated against an XML schema, or document type definition (DTD) depending on the version of the Java Servlet Specification you're declaring the webapp to use at the top of web.xml. The last one, context.xml, is also a well-formed XML document. The syntax of every important part of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required