Previous Section
Table of Contents
Next Section


Chapter 16: The Struts Configuration File

Overview

One of the core benefits to using the Struts framework is that a great deal of your application’s configuration can be specified declaratively in an external configuration file instead of being hard-coded into the application. This greatly simplifies development because many changes can be made to the application without having to recompile any code. Upon application startup, Struts loads its configuration file(s) and creates a series of configuration objects that correspond to the settings in the file. Struts then uses those configuration objects to guide its behavior.

The Struts configuration file is XML-based and its format is governed by a Document Type Definition (DTD) file that specifies how the configuration tags must be ordered in the file, what settings are required, and so on. Each Struts configuration file declares its conformance to the DTD by having the following DOCTYPE definition at the top of the file:

<!DOCTYPE struts-config PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
  "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

When Struts reads the configuration file, its XML parser uses the DOCTYPE definition to determine the DTD that the XML file must conform to. If configured to do so, the XML parser will validate the XML file’s conformance to the DTD.



Previous Section
Table of Contents
Next Section