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 ...

Get Tomcat: The Definitive Guide, 2nd 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.