Request Processor is a simple object of org.apache.struts.action.RequestProcessor class which handles the HTTP specific request and response after getting the control from the ActionServlet by calling process().

Steps of Struts Request Processing flow :

1. Clicking on submit button from JSP page, container invokes the doPost() or doGet() method based on the type of action performed. 

2. Control go to the ActionServlet which delegates the request to the Request Processor by invoking process() method.

3.  Request Processor will check for the requested resource. 

4. If request resource in not available then give the error with HTTP Status code : 404 saying  "Requested Resource is not available ".

5. If available then Request Processor checks whether that resource contain any < html : form > tag or not. 

6. If that resource doesn't contain any < html : from > tag then corresponding resource i.e JSP will be displayed .

7. If it contains < html : form > tag with form elements then Request Processor takes the reqested URI mentioned in the action attribute of the < from > tag in JSP.

8. Request Processor checks whether any < action > tag is present in the struts-config file. If present then check for the URI is available in the path attribute of the < action > tag in the struts-config file.  

9. If no matching action is found then error message will be displayed with Http Status code: 500 saying cannot retrieve mapping for the following action . 

10. And if matching action found then Request Processor gets the value of the name attribute of the < action > tag .

11. Request Processor check for the name attribute of the < form-beam > tag contains the same value as the name attribute of the < action > tag.

12. If no matching action is found then error message will be displayed with HTTP Status code: 500 saying " cannot retrieve defination for the following form bean ".

13. If the matching form bean found then Request Processor get the form bean  type and do the following tasks:

       a) Loads the respective class.
       b) Create the object of the form bean class by calling the default constructor.
       c) Store the  object in the default scope i.e session using the setAttribute() .
       d) calls the reset() method.
       e) Collect the data from the form bean object and populate in the JSP field.   

14. Invokes the execute() method with the HTTP specific request and response. 

15. If it fails to execute successfully then Exception may be throw and must be handled by the Request Processor. 

16. If executed successfully then control will get back to the Request Processor by returning ActionForward object which is preformed by calling the findForward() method with the ActionMapping instance.

17. Request Processor identifies the JSP related to the ActionForward object returned by calling the findForward() or exception throws by the execute() method. 

18. And hence identified resource ( JSP ) will be displayed to the client. 


Note : Either returned ActionForward object or Exception any one can be handles by the Request Processor for the same action performed at a time. 



2 comments:

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

Online Members

Live Traffic