By: Baski in Struts Tutorials on 2007年09月13日 [フレーム]
The Model 2 architecture for designing JSP pages is in reality, Model View Controller
(MVC) applied to web applications. Hence the two terms can be used interchangeably in the web world. MVC originated in SmallTalk and has since
made its way into Java community. Model 2 architecure and its derivatives are the cornerstones for all serious and industrial strength web applications designed
in the real world. Hence it is essential for you understand this paradigm thoroughly. Figure 1.2 shows the Model 2 (MVC) architecture.
The main difference between Model 1 and Model 2 is that in Model 2, a controller handles the user request instead of another JSP. The controller is
implemented as a Servlet. The following steps are executed when the user submits the request.
Model 2 Architecture.
Advantages of Model 2 Architecture
Since there is no presentation logic in JSP, there are no scriptlets. This means
lesser nightmares. [Note that although Model 2 is directed towards elimination of
scriptlets, it does not architecturally prevent you from adding scriptlets. This has
led to widespread misuse of Model 2 architecture.]
With MVC you can have as many controller servlets in your web application. In fact you can have one Controller Servlet per module. However there are
several advantages of having a single controller servlet for the entire web application. In a typical web application, there are several tasks that you want to
do for every incoming request. For instance, you have to check if the user requesting an operation is authorized to do so. You also want to log the user"s
entry and exit from the web application for every request. You might like to centralize the logic for dispatching requests to other views. The list goes on. If
you have several controller servlets, chances are that you have to duplicate the
logic for all the above tasks in all those places. A single controller servlet for the
web application lets you centralize all the tasks in a single place. Elegant code
and easier to maintain.
Web applications based on Model 2 architecture are easier to maintain and extend since the views do not refer to each other and there is no presentation
logic in the views. It also allows you to clearly define the roles and responsibilities in large projects thus allowing better coordination among team
members.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in Struts )
Handling Duplicate Form Submissions in Struts
Configuring JDBC DataSources in Struts
Simple example of using the requiredif Validator rule in Struts
Using JavaScript to submit a form in Struts
When is the best time to validate input in Struts
How to prepopulate a form in Struts
Guidelines for Struts Application Development
Latest Articles (in Struts)
Handling Duplicate Form Submissions in Struts
Guidelines for Struts Application Development
Configuring JDBC DataSources in Struts
When is the best time to validate input in Struts
Simple example of using the requiredif Validator rule in Struts
How to prepopulate a form in Struts
Using JavaScript to submit a form in Struts
FAQ: Why are my checkboxes not being set from ON to OFF?
FAQ: Why was reload removed from Struts (since 1.1)?
Handling Duplicate Form Submissions in Struts
Guidelines for Struts Application Development
Configuring JDBC DataSources in Struts
When is the best time to validate input in Struts
Simple example of using the requiredif Validator rule in Struts
How to prepopulate a form in Struts
Using JavaScript to submit a form in Struts
FAQ: Why are my checkboxes not being set from ON to OFF?
FAQ: Why was reload removed from Struts (since 1.1)?
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate