Monday, August 4, 2008

Locating the struts-config.xml File in Rational Application Developer Web Module

Locating the struts-config.xml File

You may be wondering: “how does the ActionServlet know how to handle the millions of requests that it is being bombarded with?”

Well, as programmers, we code these special Struts components called Action objects. The ActionServlet takes a web based request and maps it to an appropriate action class. It knows how to do this by reading the struts-config.xml file.

Open the struts-config.xml file

1. From the ‘Project Navigator’ view of the Web perspective, open the PulpJavaWeb project, open the ‘WebContent’ folder, and then open the ‘WEB-INF’ folder.

2. Under the ‘WEB-INF’ folder, double click in the struts-config.xml file to open the struts-config editor.

3. Explore the various tabs of the struts-config.xml editor. Look at the ‘Source’ tab and look at all the sad, empty elements that a good Struts application will amply populate.

The ActionServlet and the struts-config.xml file go together like sex and litigation. If you look at the ActionServlet entry in the web.xml file, you'll notice that there is an initialization parameter named 'config,' and it is associated with the 'struts-config.xml' file. When the ActionServlet first loads, it reads the struts-config.xml file and configures itself appropriately.


No comments: