Struts and Model-View-Controller (MVC) Design Pattern

Struts and Model-View-Controller (MVC) Design Pattern

Previous Home Next

 

Struts1.3 Frameworks is used to build Java-based Web applications. Struts solved many problems associated with developing high-performance, business-oriented Web applications that was in Servlets and Java Server Pages (JSP) by using the Model-View-Controller -2 (MVC-2) design patterns


 Struts ActionServlet class:-The Struts Framework gives developers to make an application that has flexibility to use any approach or technology for building the Model layer code like Object Relational Mapping (ORM) Frameworks (e.g. Hibernate or TopLinkor or iBatis), Enterprise JavaBeans (EJB), Java Data Objects (JDO), or the Data Access Objects (DAO) pattern.Model is where Struts1.3 is ends and our application code (code for business logic) beginnings .Struts provides ActionServlet class which is part of controller layer.

The org.apache.struts.action.ActionServlet is the backbone of all struts application.This is the main controller component the handle client request and processing each request .It serves as an Action Factory based on the user's request. 

All the Action class in the Struts model extends the org.apache.struts.action.Action class. The subclasses of Action class interact with the Model via interfaces and use its Data Transfer Objects to pass and retrieve data.If we are using data code or business logic on subclasses of Action class then we are making a bypass the separation of the Model layer and the Controller layer. Doing so is violating the separations of model and controller.Struts Result Component- Struts provide a so many numbers of functionality and features for developing the View layer. We can use HTML/JSP, XML/XSLT, Velocity, and Swing, to make view in Struts based applications. This is the power of Struts and MVC. Because HTML/JSP is the typical View technology used for Java-based Web applications, Struts provides the most functionality and features for developing your application this way. The remainder of this chapter focuses on Struts support for creating the View layer using HTML/JSP.


Previous Home Next