Model 2

Model 2 is a complex design patterns for the separation of display ( display of content ) and logic (reference and manipulation of such content ) in Java web applications. Therefore, it is typically associated with MVC. Although the exact form of MVC was never specified for Model 2, recommend a number of publications a formalized layer containing the MVC Model Code. For example, the use of EJBs originally recommended to encapsulate the MVC model, the Java Blueprints.

In a Model 2 application requests from the client browser to be passed to the controller. The controller performs the logic which is necessary for obtaining the contents for presentation. He then places this content in the request from (usually as JavaBean or POJO ) and decides which view he hands over the request. The view then represents the content that was presented by the controller.

Model 2 is recommended for medium and large applications.

History

Published in 1998, Sun Microsystems, a preliminary version of the JSP specification, version 0.92. This two methods are listed, with which JSP pages can be used. The first model ( Model 1 the order in the document following ) was simple, JSP pages were separate entities. Logic could even be included in the page, the navigation between the pages was usually realized by hyperlinks. ColdFusion and Active Server Pages are examples of contemporary technologies, which implemented this model.

The second model (Model 2 in order) was an improved method that combined with Servlet, JSP technology. The mentioned difference was that a servlet to intercept the request, grab the content displayed in a parameter (usually a JavaBean ), and finally a JSP would call to present the content in the desired output format. This model differed from the previous in the fact that JSP technology was used as a pure template engine. All logic was removed in a servlet, so that the sole object of the JSP was to render the provided content.

1999 succeeded Govind Seshadri formalization of the concept of Model 2 as MVC pattern for web applications that take one of two options. Given the shift in logic from the JSP into a servlet, these two as view and controller of an MVC architecture could be considered.

In March 2000, Apache Struts has been published. This project formalized separation between View and Controller and claimed to be an implementation of the Model 2 pattern. Again, the implementation of " model " was left undefined with the expectation that developers would fill it with a reasonable solution. Database interaction via JDBC and EJBs were an option that was proposed on the Struts website. Later on as more modern options Hibernate, iBATIS, and Apache OJB listed for the model

Since the release of Struts several competing frameworks have appeared. Many of them also claim that they implement Model 2 and MVC. The result is that the two terms are used interchangeably by developers, which has led to the term " MVC Model 2" or " MVC2 ".

Misconceptions

A common misconception is that a formalized MVC pattern is a prerequisite for model 2 implementation. However, the Java Blueprints warn specifically against this interpretation:

The literature on Web -tier technology in the J2EE platform frequently uses the terms " Model 1 " and " Model 2 " without explanation. This terminology stems from early drafts of the JSP specification, Which Described two basic usage patterns for JSP pages. While the terms have disappeared from the specification document, THEY REMAIN in common use. Model 1 and Model 2 simply refer to the absence or presence ( respectively) of a controller servlet did dispatches requests from the client tier and selects views.

In German translation:

The literature on Web -tier technology for the J2EE platform frequently uses the terms "Model 1" and " Model 2 " without explanation. This technology comes from early drafts of the JSP specification, which describes two basic usage pattern for JSP pages. Although the terms have disappeared from the specification document, they remain common. Model 1 and Model 2 refer simply to the absence or presence of a controller servlet that sends requests from the client tier and selects views.

Furthermore, the term " MVC2 " has led to the mistaken belief that Model 2 is the next generation of MVC. Indeed MVC2 just an abbreviation of "MVC Model 2 ".

577325
de