Chapter 4. Configuring Struts Applications

The Struts framework uses two separate but somewhat related types of configuration files, which must be configured properly before an application will work correctly. Due to the popularity, flexibility, and self-describing nature of XML, both types of configuration files are based on XML.

The web application deployment descriptor named web.xml is described fully in the Java Servlet specification.[5] This configuration file is necessary for all web applications, not just those built with the Struts framework. However, there is Struts-specific deployment information within it that must be configured when building Struts applications.

Tip

Although the Struts framework supports the 2.2 Servlet specification, many servlet containers already have support for Version 2.3. This book includes coverage of the 2.2 and 2.3 specifications.

The second configuration file that we will examine is the Struts configuration file. It is commonly named struts-config.xml, but you can name it just about anything you want. The Struts configuration file makes it possible for you to declaratively configure many of your application’s settings. You can think of the Struts configuration file as the rules for the web application.

The Storefront Application

Throughout the rest of this book, we will construct a shopping-cart type application to use for all of the examples. By the end of the book, we should have a fairly complete application that uses most of the Struts 1.1 features. Figure 4-1 shows the main page of the Storefront example application.

The main page of the Storefront application

Figure 4-1. The main page of the Storefront application

The Storefront application will demonstrate an e-commerce automotive parts supplier, but you can substitute any items you want as long as you have your own images and data to put into the application. In the end, the Storefront application will be a complete web archive (WAR) file that can be deployed into any compliant web container and used as an example for many different purposes.



[5] See the Java Servlet Specification Version 2.3, Chapter SRV.13.

Get Programming Jakarta Struts, 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.