Struts - SPLessons

Struts 2 Architecture

Home > Lesson > Chapter 3
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Struts 2 Architecture

Struts 2 Architecture

shape Description

Struts 2 Architecture is defined based on the MVC Architecture. Model View Controller is the popular design pattern which is utilized to build web applications and it consists of three parts where each one will have its own functionality, following is the conceptual figure which describes functioning of each module. Struts2 Architecture is useful for the user, to develop the Web Based Applications and it will some components in the flow of execution. Following are the components which are utilized in the Struts 2 Architecture. Interceptors are theoretically the same as servlet filters or the JDKs Proxy class. Interceptors take into account crosscutting usefulness to be executed independently from the action, framework. Interceptors are used to perform the validations, exceptions handling and display the result in between the execute() method. Struts 2 Interceptors execution is same as the servlet filter execution type.The advantage of Interceptors is, One can run the application using validations, after sometimes remove the validations on that application, and one cannot deploy the application in the server again. So, directly start the server application and execute.

shape Conceptual figure

Struts 2 Architecture
  • Client/User sends a request to Controller. In Struts2,  FilterDispatcher class act as Controller. Controller invokes the Action Invocation through structs.XML file. After that it checks the each interceptor.
  • Controller goto Action class, in Struts2 Action class and act as Model.
  • Action class will go to the database, then the result will be generated.
  • The result come to the action class and it set the values from the browser.
  • Action class gives the result to ActionInvocation.
  • ActionInvocation gives the result on View pages. Then, View page generate the Http response. In Struts2, JSP pages and act as Views.
  • Then the response goes to Client/User and displays the output in the browser page.

Summary

shape Key Points

  • Struts 2 Architecture - An Interceptor is an instance of Struts 2 utilized to perform exception handling, validation.
  • HttpServletResponse will be generated by ActionInvocation.
  • OGNL and ValueStack both are the core elements of Struts 2.