Javatpoint Logo
Javatpoint Logo

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:

  1. struts 2 basic flow
  2. 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:

struts 2 basic flow
  1. User sends a request for the action
  2. Controller invokes the ActionInvocation
  3. ActionInvocation invokes each interceptors and action
  4. A result is generated
  5. The result is sent back to the ActionInvocation
  6. A HttpServletResponse is generated
  7. 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:

struts 2 architecture
  1. User sends a request for the action
  2. Container maps the request in the web.xml file and gets the class name of controller.
  3. Container invokes the controller (StrutsPrepareAndExecuteFilter or FilterDispatcher). Since struts2.1, it is StrutsPrepareAndExecuteFilter. Before 2.1 it was FilterDispatcher.
  4. Controller gets the information for the action from the ActionMapper
  5. Controller invokes the ActionProxy
  6. ActionProxy gets the information of action and interceptor stack from the configuration manager which gets the information from the struts.xml file.
  7. ActionProxy forwards the request to the ActionInvocation
  8. ActionInvocation invokes each interceptors and action
  9. A result is generated
  10. The result is sent back to the ActionInvocation
  11. A HttpServletResponse is generated
  12. Response is sent to the user





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA