When the ActionServlet receives a request, it completes the following steps:
1.The doPost() or doGet() methods receive a request and invoke the process() method.
2.The process() method gets the current RequestProcessor and invokes the RequestProcessor. process() method.
3.The RequestProcessor.process() method is where the current request is actually serviced. This method retrieves, from the struts-config.xml file, the <action> element that matches the path submitted on the request. It does this by matching the path passed in the <html:form /> tag's action element to the <action> element with the same path value. Here's an example of this match:
<html:form action="/Lookup"
name="lookupForm"
type="ch04.LookupForm" >
<action path="/Lookup"
type="ch04.LookupAction"
name="lookupForm" >
<forward name="success" path="/quote.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
4.When the RequestProcessor.process() method has a matching <action>, it looks for a <form-bean> entry that has a name attribute that matches the <action> element's name attribute. The following code snippet contains a sample match:
<form-beans>
<form-bean name="lookupForm"
type="ch04.LookupForm"/>
</form-beans>
<action path="/Lookup"
type="ch04.LookupAction"
name="lookupForm" >
<forward name="success" path="/quote.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
5.When the RequestProcessor.process() method knows the fully qualified name of the FormBean, it creates or retrieves a pooled instance of the ActionForm named by the <form-bean> element's type attribute and populates its data members with the values submitted on the request.
6.After the ActionForm's data members are populated, the RequestProcessor.process() method calls the ActionForm.validate() method, which checks the validity of the submitted values.
7.At this point, the RequestProcessor.process() method knows all that it needs to know and it is time to actually service the request. It does this by retrieving the fully qualified name of the Action class from the <action> element's type attribute, creating or retrieving the named class, and calling the Action.execute() method.
8.When the Action class returns from its processing, its execute() method returns an ActionForward object that is used to determine the target of this transaction. The RequestProcessor.process() method resumes control, and the request is then forwarded to the determined target.
9.At this point, the ActionServlet instance has completed its processing for this request and is ready to service future requests.
Configuring the ActionServlet :
Parameter | Description |
config | Names the context-relative path to the struts-config.xml file. The default location is in the /WEB-INF/struts-config.xml directory. (Optional) |
config/${module} | Names the context-relative path to the struts-config.xml file associated with a particular Struts Module. (Optional) |
convertNull | A boolean parameter used to simulate Struts 1.0x functionality when populating an ActionForm. When this parameter is set to true, numeric objects (java.lang.Integer, etc.) are initialized to null. If it is set to false, these objects are set to 0. |
debug | Determines the debugging level for the ActionServlet. The default value is 0, which turns debugging off. (Optional) |
detail | Sets the debug level for the Digester object, which is used during ActionServlet initialization. The default value is 0. (Optional) |
multipartClass | Names the fully qualified class of the MultipartRequestHandler implementation to be used when file uploads are being processed. The default value is org.apache.struts.upload.DiskMultipartRequestHandler. (Optional) |
validating | If set to true, tells the ActionServlet that we want to validate the strut-config.xml file against its DTD. While this parameter is optional, it is highly recommended and therefore the default is set to true. |