Overview of Struts Framework

Overview of Struts Framework
  • Open source
  • Based on the Model-View-Controller (MVC) design paradigm, distinctly separating all three levels:
    • Model: application state
    • View: presentation of data (JSP, HTML)
    • Controller: routing of the application flow
  • Implements the JSP Model 2 Architecture
  • Stores application routing information and request mapping in a single core file, struts-config.xml
  • The Struts Framework, itself, only fills in the View and Controller layers. The Model layer is left to the developer.
Architecture Overview
 
Struts Architecture Overview

Struts Architecture Overview

All incoming requests are intercepted by the Struts servlet controller. The Struts Configuration file struts-config.xml is used by the controller to determine the routing of the flow. The flow consists of an alternation between two transitions:
  1. From View to Action : A user clicks on a link or submits a form on an HTML or JSP page. The controller receives the request, looks up the mapping for this request, and forwards it to an action. The action in turn calls a Model layer (Business layer) service or function.
  2. From Action to View: After the call to an underlying function or service returns to the action class, the action forwards to a resource in the View layer and a page is displayed in a web browser.
Process Flow
Struts Process Flow

Struts Process Flow

  1. User clicks on a link in an HTML page.
  2. Servlet controller receives the request, looks up mapping information in struts-config.xml, and routes to an action.
  3. Action makes a call to a Model layer service.
  4. Service makes a call to the Data layer (database) and the requested data is returned.
  5. Service returns to the action.
  6. Action forwards to a View resource (JSP page)
  7. Servlet looks up the mapping for the requested resource in struts-config.xml  and forwards to the appropriate JSP page.
  8. JSP file is invoked and sent to the browser as HTML.
  9. User is presented with a new HTML page in a web browser.
Source : Struts Tutorial
See Also : Java Brains
Rate this post

Leave a Reply