Struts flow (Struts Request Processing Flow)

When we started the server after deploying Struts based web application then following tasks will happen at container start up.
  1. Container initializes the Action Servlet because of <load-on-startup> tag
  •  Load the Action Servlet class instance
  • Create the Action Servlet Instance.
  • Create the ServletConfig Object and initialize the ServletConfig object with init parameter.
  • Invoke the init() method by passing ServletConfig Object parameter.    
   2.     init() method is responsible for parsing the data from struts configuration document.
   3.   If any errors found while parsing XML then Action Servlet will be not initialize and will not be ready to serve the request.
    4. If no error fond while parsing XML then Action Servlet will be initialized and ready to serve the request with url-pattern *.do.

Here see web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns=""

Now when client send the request for resource then following thing happen:
  • Container invoke the service() method of Action Servlet.
  • Action Servlet delegates the request to Request Processor.
  • Request Processor starts processing the given request by doing the following tasks:
  1. Request Processor checks whether the requested resource available or not.
  2. If the request resource is not available then error message will be given as Http Status code:404.
  3. If the requested resource is then Request Processor checks whether the Resource(JSP) contains any <html:form> tag.
  4. If the identified resource does not contained any <html:form> tag then error message will be given as can't find bean  org.apache.struts.taglib.html.BEAN in any scope
  5. If the identified resource contain <html:form> tag then takes the Request URI
  6. Request Processor checks whether any <action> tag in available in struts-cofig.xml file whose path attribute values is same as action attribute value.
  7. If no matching action is found then error message will be given as -500:Can't retrieve mapping for action /your given url
  8. If matching action is found the Request Processor take form bean name.
  9. Request Processor checks whether any <form-bean> tag is available in struts-config.xml file whose attribute value is same as action name attribute value.
  10. If no matching form bean is found then error will given as -500: can't retrieve definition for form bean(your form bean name as like loginForm).
  11. If matching is form bean is found then Request Processor take the Form Bean type which is the Form bean java class.
  12. Request Processor stats the Form Bean life cycle as
  • Load the form bean java class.
  • Create the form bean java class object by calling default constructor.
  • Store the form bean object in the given scope
  • call the reset(0 method.
  • collect the data from form bean object by calling getter method and populates the data in jsp form field
    13. Identified resource will be rendered to client.
    14. If validate() method found then invoke the validate() method.
    15. Create or retrieve Action Class Object.
    16. Invoke execute() method.
    17. execute() method may return Action Forward object on the successful completion or exception.
     18. Request Processor identifies the jsp related to Action Forward object returned or exception thrown    
     execute() method.
    19. Finally identified jsp will be rendered to client.