Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Detailed introduction to Struts 2 Architecture 
 

In the previous section we learned about MVC framework and in this section we will learn about the different components of Struts 2 framework.

 

Detailed introduction to Struts 2 Architecture

                         

Struts 2 Framework Architecture
In the previous section we learned about MVC framework and in this section we will learn about the different components of Struts 2 framework.

How Struts 2 Framework works?

Suppose you are accessing the product list page in a Struts 2 shopping cart application and typing <your-domain/showproducts.action> to get the list of all the products available for purchase. In any Struts 2 application *.action is the default mapping configured in web.xml file. Suppose the name of the action is showpoducts.action, which retrieves the data from the model (database) and displays on the browser. In this scenario the request processing steps can be summarized into blow mentioned steps:

  1. The browser requests for showproducts.action.
  2. The Filter Dispatcher of Struts 2 framework looks at the request and determines the appropriate Action. In this case "showproducts".
  3. Next the Interceptors are applied. The Interceptors are used to apply common functionality to the request such as like workflow, validation, and file upload handling.
  4. Then the action method is executed. In our example appropriate method on the action (showproducts) is executed to retrieve the product list data from model.
  5. Finally the Result renders the output to the browser in the form of product list.  

Following diagram shows the high level architecture of Struts 2 Framework:

Struts 2 Architecture

 

Detailed Architecture of Struts 2 Framework

Following diagram shows the detailed architecture of Struts 2 Framework.

Struts 2 Detailed Architecture

The above diagram depicts the architecture of Struts 2 Framework. Following diagram shows that the initial request goes to the servlet container, which is then passed through standard filer chain.

The filter chain includes:

1. Action ContextCleanUp filter: The ActionContextCleanUp filter is optional and it is useful when integration has to be done with other technologies like SiteMash Plugin.

2. FilterDispatcher: Next the FilterDispatch is called, which in turn uses the ActionMapper to determine weather to invoke an Action. If the action is required to be invoked, the FilterDispatcher delegates the control to the ActionProxy.

3. ActionProxy: The ActionProxy takes the help from Configuration Files manager, which is initialized from the struts.xml. Then the ActionProxy creates an ActionInvocation, which implements the command pattern. The ActionInvocation process invokes the Interceptors (if configured) and then invokes the action. The ActionInvocation looks for proper result. Then the result is executed, which involves the rendering of JSP or templates.

Then the Interceptors are executed again in reverse order. Finally the response returns through the filters configured in web.xml file. If the ActionContextCleanUp filter is configured, the FilterDispatcher does not clean the ThreadLocal ActionContext. If the ActionContextCleanUp filter is not present then the FilterDispatcher will cleanup all the ThreadLocals present.

Struts 2 Core components

Struts 2 Core components are Action handler, Result Handler and Custom Tags

  • Action handler
    Action handler interacts with other layers
  • Result Handler
    Result handler actually dispatches the request to view.
  • Custom Tags
    Custom Tags are used render the dynamic content
  • Interceptors
    Interceptors allows to add some custom logic such as authentication, file upload to an action. Interceptors code is executed before and after an Action is invoked
  • Value Stack
    The ValueStack allows the expression language to find property values across multiple objects. Thus Struts2 tags can access data from the action very easily. 
  • Expression Language
    Struts 2 expression language can be used for getting and setting properties of Java objects

We will learn about these core components in the future lessons.

                         
 

» View all related tutorials
Related Tags: c mvc com framework diff struts io components vi component this frame if work learn ram ear e il section

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.