Struts 2 Architecture and Flow
The architecture and flow of struts 2 application, is combined with many components such as Controller, ActionProxy, ActionMapper, Configuration Manager, ActionInvocation, Inerceptor, Action, Result etc.
Here, we are going to understand the struts flow by 2 ways:
- struts 2 basic flow
- struts 2 standard architecture and flow provided by apache struts
Struts 2 basic flow
Let's try to understand the basic flow of struts 2 application by this simple figure:
- User sends a request for the action
- Controller invokes the ActionInvocation
- ActionInvocation invokes each interceptors and action
- A result is generated
- The result is sent back to the ActionInvocation
- A HttpServletResponse is generated
- Response is sent to the user
Struts 2 standard flow (Struts 2 architecture)
Let's try to understand the standard architecture of struts 2 application by this simple figure:
- User sends a request for the action
- Container maps the request in the web.xml file and gets the class name of controller.
- Container invokes the controller (StrutsPrepareAndExecuteFilter or FilterDispatcher). Since struts2.1, it is StrutsPrepareAndExecuteFilter. Before 2.1 it was FilterDispatcher.
- Controller gets the information for the action from the ActionMapper
- Controller invokes the ActionProxy
- ActionProxy gets the information of action and interceptor stack from the configuration manager which gets the information from the struts.xml file.
- ActionProxy forwards the request to the ActionInvocation
- ActionInvocation invokes each interceptors and action
- A result is generated
- The result is sent back to the ActionInvocation
- A HttpServletResponse is generated
- Response is sent to the user
|