Struts MVC

Struts is an application framework that allows the construction of dynamic Web applications using the MVC design pattern.

  • The Controller layer is implemented by Servlets. 
  • The view is implemented using JSPs. 
  • The Model layer is typically implemented using JavaBeans or Enterprise JavaBeans.

Struts MVC Architecture




Controller Components

Struts' main Controller components consist of a Front Controller servlet, ActionServlet, and the ActionForm and Action classes. 

ActionServlet
The ActionServlet receives an HTTP request, invokes the requested actions on the Model and selects the next view to display. It is the core of the framework. One instance of the ActionServlet class receives all incoming requests. The ActionServlet sets the state of an ActionForm using corresponding fields from the HTTP request, optionally asks it to validate itself and passes it to a mapped Action. Requests are mapped to Actions using a configuration file (struts-config.xml).

ActionForm
The ActionForm class represents the form data. The ActionServlet instance automatically populates its properties with values from the input form and passes it to the requested Action. The ActionForm is also used to hold dynamic data from the Model to be displayed by the View.
Action
The Action class contains logic to call the Model layer. When executed by the ActionServlet, it invokes Model objects to perform the business logic, and then tells the ActionServlet Controller where to go next.

Model

Struts does not specify which technology to use for the Model. Most commonly, however, Model objects are implemented using simple JavaBeans or more powerful components such as Enterprise JavaBeans.

View

The View is typically implemented using JavaServer Pages to take advantage of the JSP Custom Tag libraries provided with the framework. The dynamic data to be displayed is retrieved from JavaBeans or instances of the ActionForm class created by the Controller layer. Custom tags are the primary mechanism for accessing this data.

Whats is the difference between Struts and Spring framework?

Spring is loosely coupled while Struts is tightly coupled. Spring provides easy integration with various technologies while in struts, we need to do coding manually. Struts MVC is more suitable for applications which involve minimum integration points with other systems/technologies. Spring IOC make integration very easy.

Comments

Popular posts from this blog

jQgrid reload with new data

Rich Client based UI technologies- A Comparison of Thick Client UI tools

OSS and BSS Systems