Struts 2 is the Open source web application Framework which simplified the creation of Web Applications in in Java. It is based on the Model – View – Framework (MVC) architect which is originally found in language “SmallTalk”. Latest version of Struts is 2 and which is created by using concepts of WebWork and Xwork.
Flow of Struts 2:
- Request : Client makes the request.
- Filter Dispatcher : As Boot Strap component is specified in Deployment Descriptor file. In Case of Struts 2, it is Servlet Filter (Filter Dispatcher). Filter Dispatcher looks the request and then as per the mapping of URL, request is forwarded to appropriate Action Class.
- Interceptor Stacks : Before going to Action Class, request goes to Interceptor Stacks (Action class mapping found in configuration file, and from there, list of interceptors identified which must be processed before Action class) .
- Action Class : Then the request object is passed to Action Class. Action Class then executes the code and after execution it returns the result code to the Controller. (either SUCCESS or INPUT or ERROR)
- Result : On the basis of result code, Controller then selects View to be rendered as a result of Action.
- Interceptors Stack : Before sending response back to client, again interceptors run.
- Response returned to User.
Note: If interceptor changes the result return type then the view will be changed and decided after interceptor.