Struts

How Struts enforces the MVC pattern
Previous Home Next

The architecture of Struts provides a wonderful mechanism that, ensures that the MVC pattern remains intact. Although Struts provides a connections between the Controller and Model layers and between the Controller and View layers, it doesnít insist on any particular View paradigm or require that you construct the Model in a particular way.

 

  • The Struts View : Struts have a weak point that it doesn't provide, nor is it dependent on, a specific presentation technology. Many Struts applications use JSP (JavaServer Pages) along with the Struts tag library (Struts and Struts-EL), JSTL (JSP Standard Tag Library), JSF (Java Server Faces) and HTML file.
  • The Struts Controller : The primary controller class is a Java Servlet called the ActionServlet. This class handles all user requests for Struts-managed URLs by using information from the configuration files, the ActionServlet class then gets the appropriate RequestProcessor class that collects the data that is part of the request and puts it into an ActionForm, a Bean that contains the data sent form or to the userís form.
  • The final step of the Struts controller is to delegate control to the specific handler of this request type, and important point is this handler is always a subclass of the Action class. The Action subclass is the main workhorse of the Controller because it monitor at the data from the userís request (now residing in an ActionForm) and determines what action needs to be taken. It may call on the business logic of the Model to perform the action, or it may forward the request to some other View.
  • The Struts Model : In the MVC design pattern, the Model provides access to the necessary business data as well as the business logic needed to manipulate that data. The connection between the Controller and Model rests in the code that you write in the Action subclasses. The Action subclasses contain the analysis of the userís request that determines the interaction (if any) with the Model.
  • The Struts configuration file : Although it is not really part of the Model, View, or Controller, and it does affect the functioning of the three layers. But the Struts configuration file performs an important role in structuring your Struts application. The configuration file allows you to define exactly which of your Action subclasses should be used under what circumstances and which ActionForm should be given to that Action subclass. So you specify part of the Controller interaction in the configuration file.
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: