Architecture of Struts 2

Struts 2 Architecture is based on WebWork 2 framework and is lot different compared to 1.x variants. It uses the standard JEE technologies such Filters, JavaBeans, ResourceBundles, Locales, XML.
Struts 2 architecture

  • ActionContextCleanUp : Used for integration with SiteMesh Plugin. It is an optional filter.
  • OtherFilters (Site Mesh) : SiteMesh is a web-page layout and decoration framework and web application integration framework to aid in creating large sites consisting of many pages for which a consistent look/feel, navigation and layout scheme is required.
  • Filter Distapacher : The FilterDispatcher filter determines which Action should be invoked and seeks advice from ActionMapper to achieve this.
  • Action Mapper : If ActionMapper finds an Action to be invoked based on the mappings, the FilterDispatcher gives the control to ActionProxy.
  • Action Proxy : ActionProxy reads the configuration file such as struts.xml and creates an instance of ActionInvocation class and delegates the control.
  • Action Invocation : ActionInvocation is responsible to invoke the Interceptors one by one (lined up before Action) and then invoke the Action.
  • Result : After the Action returns, the ActionInvocation is responsible for looking up the result associated with the Action result code mapped in struts.xml.
  • Interceptor : The Interceptors are executed again in reverse order and the response is returned to the Filter (In most cases to FilterDispatcher). And the result is then sent to the Servlet container which in turns send it back to client in form of HTTP response.

Develop Struts First Application

For Creating Struts First Program, You required the Following things Step-1 :Build Liabrary path

Step-2 : Add the Library in the Deployment Assembly

Step-3 :Entry in Web.xml

Step-4 :HelloAction DTO class

Step-5 :Hello.jsp file

Step-6 :Struts.xml file

Step-7 :Output at Web Browser

Step-8 :Login Page Demo File

Step-9 :Login.jsp File

Step-10 :LoginAction class file

Step-11 :Entry Welcome.jsp File

Step-12 :Error.jsp File

Step-13 :Struts.xml new entry