ArticleslgStudy

computer science

JSP model 2 architecture

JSP model 2 architecture is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand JSP model 2 architecture rather than just read about it. In short: JSP Model 2 is a design pattern used in the design of Java Web applications 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.

JSP model 2 architecture — main illustration
JSP model 2 architecture — illustration

Key takeaways

  • JSP model 2 architecture belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect JSP model 2 architecture to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of JSP model 2 architecture from memory before moving on to harder problems.

Reference excerpt

JSP Model 2 is a design pattern used in the design of Java Web applications 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 EJBs to encapsulate the MVC Model. In a Model 2 application, requests from the client browser are passed to the 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. In this specification, Sun laid out two methods by which JSP pages could be used. The first model (referred to as "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. 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. 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 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. 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 EJBs were options suggested on the Struts homepage. More recently, Hibernate, iBatis, and Object Relational Bridge were listed as more modern options that could be used for a model. 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:

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. 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". 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

External links Seshadri, Govind (December 29, 1999). "Understanding JavaServer Pages Model 2 architecture". JavaWorld. Retrieved 2020-07-17. A History of MVC, Including Model 2 ASP.NET Presentation Patterns - In this article Dino Esposito discusses how Model2 is also used in ASP.NET MVC.

Illustrations

JSP model 2 architecture: A simplified diagram of the Model 2 pattern.
A simplified diagram of the Model 2 pattern.

Worked examples

Example 1 — a first encounter with JSP model 2 architecture

Start with the simplest possible case. Write down what JSP model 2 architecture claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to JSP model 2 architecture before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about JSP model 2 architecture ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of JSP model 2 architecture

In research
JSP model 2 architecture appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses JSP model 2 architecture in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
JSP model 2 architecture is common in secondary-school and first-year university syllabi. It links to neighbouring topics Software architecture, Software design patterns, so understanding it makes those chapters shorter.
In everyday life
Look for JSP model 2 architecture outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “JSP model 2 architecture” →

How to study JSP model 2 architecture in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what JSP model 2 architecture means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain JSP model 2 architecture out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is JSP model 2 architecture in simple terms?

JSP Model 2 is a design pattern used in the design of Java Web applications 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) par…

Why does JSP model 2 architecture matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study JSP model 2 architecture?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on JSP model 2 architecture.

Tags

  • Software architecture
  • Software design patterns

Keep exploring