Before you start
This tutorial shows Java™ Web developers how to set up Apache Struts to use multiple configuration files. You'll learn about the purpose and structure of the various Struts configuration files and the rationale for working with smaller files. You'll follow steps to split a large, complex struts-config.xml file for an existing Struts application into multiple configuration files that are organized by function. Having smaller, more manageable parts to work with makes a Struts application easier to organize and reconfigure, and it can help you more easily identify points of failure when problems occur. You'll also learn about some other types of cleanup you can do to improve your Struts configurations.
Who should take this tutorial?
This tutorial is written for Java Web developers who have at least some basic experience with Apache Struts and the Apache Tomcat servlet engine. You should know how to start and stop Tomcat, install Struts, and deploy a Struts application.
You can use a servlet engine other than Tomcat (Struts plays quite well with other servlet engines), provided you know how to set it up and configure it. The tutorial assumes you're using Tomcat and provides no extra detail for non-Tomcat configurations. See Resources for a link to Struts documentation on installing Struts on non-Tomcat servlet containers.
Struts uses XML configuration files, so you should be comfortable with XML. But you don't need to be a configuration guru because I'll provide some basic information on how Struts uses these files before I go into the details of breaking them up.
You need a machine -- or ISP -- that has a servlet engine installed. I highly recommend you run through this tutorial either locally, on a development machine, or on a nonproduction ISP account. Don't use a machine serving thousands of users because you'll need to make changes to your servlet container (and if your servlet engine doesn't automatically reload the changes, you'll also need to restart the container manually).
Although neither is required for this tutorial, I'm using Tomcat 5.5.9 and Java 5.0 (Release 1) on Mac OS X. Java 1.4 works just as well, but you might see some compiler warnings in the tutorial examples that you won't see with earlier JVMs. I urge you to use at least version 5.0 of Tomcat; 5.5.x is even better. You also need a text editor of your choice for working with XML.
Obviously, you need Struts installed; if you're unclear on how to install Struts, check out the appendix of Using the Struts Validator, which walks you through the entire process step by step. You can also refer to Resources in this tutorial for several more good links to help you out.
Finally, in this tutorial you'll configure the Struts Online Banking application, described in Programming Jakarta Struts by Chuck Cavaness (see Resources), so you need to obtain and install it as well:
- Go to http://examples.oreilly.com/0596006519/.
- Download jakarta2ed-source.zip.
- Expand the ZIP file.
- Drop banking.war into your servlet engine's Web application directory.


