JavaFAQ Home » JSP, Servlets
Question: What are JSP Model 1 and Model 2 architectures?
Answer: The JSP specification presents two approaches for building
web applications using JSP pages: JSP Model 1 and Model 2 architectures. These
two models differ in the location where the processing takes place. In Model 1
architecture, the JSP page is responsible for processing requests and sending
back replies to clients.
The Model 2 architecture,
integrates the use of both servlets and JSP pages. In this mode, JSP pages are
used for the presentation layer, and servlets for processing tasks. The servlet
acts as a controller responsible for processing requests and creating any beans
needed by the JSP page. The controller is also responsible for deciding to which
JSP page to forward the request. The JSP page retrieves objects created by the
servlet and extracts dynamic content for insertion within a template.
This model promotes the use of the Model View Controller (MVC) architectural
style design pattern. Note that several frameworks already exist that implement
this useful design pattern, and that truly separate presentation from content.
The Apache Struts is a formalized framework for MVC. This framework is best used
for complex applications where a single request or form submission can result in
substantially different-looking results.
The answer was found in the article "Servlets and JSP Pages Best Practices":
If you are going to use
Model 2 in your project I advise you to pay attention to Struts - an open source
framework for building web applications.
Struts is part of the Apache Jakarta Project, sponsored by the Apache Software
The core of the Struts framework is a flexible control layer based on standard
technologies like Java Servlets, JavaBeans, ResourceBundles, and Extensible
Markup Language (XML), as well as various Jakarta Commons packages. Struts
encourages application architectures based on the Model 2 approach, a variation
of the classic Model-View-Controller (MVC) design paradigm.
Struts provides its own
Controller component and integrates with other technologies to provide the Model
and the View. For the Model, Struts can interact with standard data access
technologies, like Enterprise Java Beans and JDBC, as well as most any
third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For
the View, Struts works well with JavaServer Pages, including JSTL and JSF, as
well as Velocity Templates, XSLT, and other presentation systems .
The Struts framework
provides the invisible underpinnings every professional web application needs to
survive. Struts helps you create an extensible development environment for your
application, based on published standards and proven design patterns.
Struts can be taken here:
Our older tips: March 22, 2001 - October 21, 2002
All published and not published on the site tips read
Printer Friendly Page
Send to a Friend
Search here again if you need more info!