Blog on things around me - Applications, Java Platform, Free & Open Source Software, Gadgets, Utilities...
The MVC architectural pattern is not directly related to web applications. In fact, it's quite common in Smalltalk applications, which generally have nothing to do with the Web.The Model 2 approach is concerned with separating responsibilities in web applications. Allowing a JSP page to handle the responsibilities of receiving the request, executing some business logic, and then determining the next view to display can make for an unattractive JSP page, not to mention the maintenance and extensibility problems this entanglement causes. Application development and maintenance are much easier if the different components of a web application have clear and distinct responsibilities.The MVC ModelDepending on the type of architecture your application uses, the model portion of the MVC pattern can take many different forms. In a two-tier application, where the web tier interacts directly with a data store such as a database, the model classes may be a set of regular Java objects. These objects may be populated manually from a ResultSet returned by a database query, or they may be instantiated and populated automatically by an object-to-relational mapping (ORM) framework such as TopLink or CocoBase.The MVC ViewThe views within the web tier MVC pattern typically consist of HTML and JSP pages. HTML pages are used to serve static content, while JSP pages can be used to serve both static and dynamic content.Most dynamic content is generated in the web tier. However, some applications may require clientside JavaScript. This does not interfere with or infringe upon the MVC concept.HTML and JSP are not the only choice for the view. You easily can support WML, for example,instead of HTML. Because the view is decoupled from the model, you can support multiple views, each for a different client type, using the same model components.The MVC ControllerThe controller portion of the web tier MVC design generally is a Java servlet. The controller in a web tier application performs the following duties:
Here is a graphical repersentation of a typical struts based application.
Thanks for clarifying things with your post. You make it very obvious why Model 2/MVC is preferred to Model 1 and its dependence on monolithic JSPs.I do have one question, however. In your illustration, what is the difference between the "Business Logic" module and the "Model" module?Regards.
Post a Comment
Lalit Modi, the mastermind behind the Indian Premier League (IPL), recently had a candid interview with Raj Shamani. The interview delved d...
1 comment:
Thanks for clarifying things with your post. You make it very obvious why Model 2/MVC is preferred to Model 1 and its dependence on monolithic JSPs.
I do have one question, however. In your illustration, what is the difference between the "Business Logic" module and the "Model" module?
Regards.
Post a Comment