Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
JSP model 2 architecture
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[[File:JSP Model 2.svg|thumb|alt=A diagram of a Model 2 implementation.|A simplified diagram of the Model 2 pattern.]] '''JSP Model 2''' is a complex [[design pattern (computer science)|design pattern]] used in the design of [[Java (programming language)|Java]] [[Web application]]s which separates the display of content from the logic used to obtain and manipulate the content. Since Model 2 drives a separation between logic and display, it is usually associated with the [[model–view–controller]] (MVC) paradigm. While the exact form of the MVC "Model" was never specified by the Model 2 design, a number of publications recommend a formalized layer to contain MVC Model code. The [[Java BluePrints]], for example, originally recommended using [[EJB]]s to encapsulate the MVC Model. In a Model 2 application, requests from the [[client (computing)|client]] [[web browser|browser]] are passed to the [[Control logic|controller]]. The controller performs any logic necessary to obtain the correct content for display. It then places the content in the request (commonly in the form of a [[JavaBean]] or [[POJO]]) and decides which view it will pass the request to. The view then renders the content passed by the controller. Model 2 is recommended for medium- and large-sized applications. ==History== In 1998, Sun Microsystems published a pre-release of the [[JavaServer Pages]] specification, version 0.92.<ref>[http://www.kirkdorffer.com/jspspecs/jsp092.html#model JSP 0.92 Specification]</ref> In this specification, Sun laid out two methods by which JSP pages could be used. The first model (referred to as "[[JSP model 1 architecture|model 1]]" due to its ordering in the document) was a simplistic model whereby JSP pages were standalone, disjointed entities. Logic could be contained within the page itself, and navigation between pages was typically achieved by way of hyperlinks. This fit with the then-common usage of template technology. [[ColdFusion]] and [[Active Server Pages]] are examples of contemporary technologies that also implemented this model. The second model referred to by the document ("model 2" in the ordering) was an improved method that combined [[servlet]] technology with JSP technology. The specific difference listed was that a servlet would intercept the request, place the content to render into a request attribute (typically represented by a JavaBean), then call a JSP to render the content in the desired output format. This model differed from the previous model in the fact that JSP technology was used as a pure template engine. All of the logic was separated out into a servlet, leaving the JSP with the sole responsibility of rendering the output for the content provided. In December 1999, JavaWorld published an article by Govind Seshadri entitled ''Understanding JavaServer Pages Model 2 architecture''.<ref>{{cite web |last1=Seshadri |first1=Govind |date=1999-12-29 |df=mdy |url=https://www.infoworld.com/article/2076557/understanding-javaserver-pages-model-2-architecture.html |title=Understanding JavaServer Pages Model 2 architecture |work=[[JavaWorld]] |access-date=2020-07-17}}</ref> In this article, Govind accomplished two major milestones in the use of the term "Model 2". The first milestone was to formalize the term "Model 2" as an [[architectural pattern]] rather than one of two possible options. The second milestone was the claim that Model 2 provided an MVC architecture for web-based software.<ref name="strutsModel2">[http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/chap2_0672324725.pdf How Struts Implements Model 2 (The Origins of Model 1/Model 2)]</ref> Govind believed that because "Model 2" architecture separated the logic out of the JSP and placed it in a servlet, the two pieces could be seen as the "View" and the "Controller" (respectively) in an MVC architecture. The "Model" part of the MVC architecture was left open by Govind, with a suggestion that nearly any data-structure could meet the requirements. The specific example used in the article was a [[Java Collections|Vector]] list stored in the user's session. In March 2000, the [[Apache Struts]] project was released. This project formalized the division between View and Controller and claimed implementation of the "Model 2" pattern.<ref name="strutsModel2" /> Once again, the implementation of the "Model" was left undefined with the expectation that software developers would fill in an appropriate solution. Database interaction via [[JDBC]] and [[EJB]]s were options suggested on the Struts homepage. More recently, [[Hibernate (Java)|Hibernate]], [[IBATIS|iBatis]], and [[Object Relational Bridge]] were listed as more modern options that could be used for a model.<ref>{{Cite web |url=http://struts.apache.org/1.x/ |title=Struts 1.x Homepage |access-date=2010-10-05 |archive-url=https://web.archive.org/web/20100923130649/http://struts.apache.org/1.x/ |archive-date=2010-09-23 |url-status=dead }}</ref> Since the release of Struts, a number of competing frameworks have appeared. Many of these frameworks also claim to implement "Model 2" and "MVC". In result, the two terms have become synonymous in the minds of developers. This has led to the use of the term "MVC Model 2" or "MVC2" for short. ==Misconceptions== A common misconception is that a formalized MVC pattern is required to achieve a Model 2 implementation. However, the Java BluePrints specifically warn against this interpretation:<ref>[http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html#1078527 Java BluePrints 4.4.1: Structuring the Web Tier]</ref> <blockquote>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 that dispatches requests from the client tier and selects views.</blockquote> Furthermore, the term "MVC2" has led many to a mistaken belief that Model 2 represents a next-generation MVC pattern. In fact, MVC2 is simply a shortening of the term "MVC Model 2".<ref>[http://www.ibm.com/developerworks/library/j-struts/#h4 Struts, an open-source MVC implementation]</ref> The confusion over the term "MVC2" has led to additional confusion over Model 1 code, resulting in common usage of the nonexistent term "MVC1". ==See also== * [[Apache Struts]] is an open-source framework for implementing web-applications based on a Model 2 architecture. ==References== {{Reflist}} ==External links== * {{cite web |last1=Seshadri |first1=Govind |date=1999-12-29 |df=mdy |url=https://www.infoworld.com/article/2076557/understanding-javaserver-pages-model-2-architecture.html |title=Understanding JavaServer Pages Model 2 architecture |work=[[JavaWorld]] |access-date=2020-07-17}} * [http://kasparov.skife.org/blog/src/java/mvc.html A History of MVC, Including Model 2] * [https://docs.microsoft.com/en-us/archive/msdn-magazine/2008/december/cutting-edge-asp-net-presentation-patterns ASP.NET Presentation Patterns] - In this article Dino Esposito discusses how Model2 is also used in ASP.NET MVC. {{Design Patterns patterns}} [[Category:Software design patterns]] [[Category:Software architecture]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Design Patterns patterns
(
edit
)
Template:Reflist
(
edit
)