Showing posts with label J2EE. Show all posts
Showing posts with label J2EE. Show all posts

Friday, January 24, 2014

Struts Framework - Introduction to Struts

General

Struts is a framework from the Apache Software Foundation (www.apache.org) for creating J2EE applications using an MVC (model-view-controller) architecture. It is open-source software that extends the Java Servlet API and the latest evolution of this is in the Apache Struts 2 Framework which was released in February 2007. The original Struts 1.x version has reached end of life and is no longer supported by the Apache Software Foundation.  For purposes of this article, I am limiting the discussion to Struts2.

At the core, as previously mentioned is the need to create applications using the MVC architecture. Figure 1 illustrates, albeit simplistically, the MVC architecture as it is used in Struts2.

Figure 1: Simplistic Struts2 MVC Architecture

Description of Process Flow (refer to Figure 1)

  1. The HTTP servlet request is received from the interaction of the user with the JSP/HTML in their browser.
  2. The Action Mapper passes the request to one or more interceptors.
  3. The Interceptors refine and pass the requested Action to the Model.
  4. The Action then interacts with the database or some external system (possibly via MQ)
  5. The Action passes the completed action to the Result.
  6. The Result response is passed to the Template to generate the output (JSP, JSF, JasperReport, etc)
  7. The templated result is then passed in reverse order through the interceptors it arrived through as an action request.
  8. The HTTP servlet response is sent to the browser for display of the result to the User.