When JSP was introduced and after a huge success it was thought to be the end of servlets. But JSP did not displace the Servlets.
Actually today real world application are using Servlets as well as JSPs .So why still Servlets are used not obsolete after arrival of JSPs. So lets understand the two design Models upon which you can build your Java Web Application.
First design model is called Model 1,introduced after the invention of JSP ,Servlets are not normally used in this model.
Navigating from one JSP to another is done by clicking a link on the page
The second design model is named Model 2. You will learn shortly why Model 1 is not recommended and why Model 2 is the way to go.
The Problems with Model 1
Model 1 applications have a series of JSPs where the user navigates from
one page to another. This is the model you employ when you first learn
JSP because it is simple and easy.
- The Model 1 design model is page-centric.
- The main trouble with Model 1 applications is that they are hard to maintain and inflexible.
- This architecture does not promote the division of labor between the page designer and the web developer because the developer is involved in both page authoring and business logic coding.
- Navigation problem. If you change the name of a JSP that is referenced by other pages, you must change the name in many locations.
- There is more temptation to use scriptlets in JSPs because JavaBeans are limited and custom tags are hard to write. However, as explained above, mixing Java code and HTML in JSPs is a bad thing
- If you can discipline yourself to not write Java code in JSPs, you'll end up spending more time developing your application because you have to write custom tags for most of your business logic. It's faster to write Java code in Java classes.
Model 2
The second design model is simply called Model 2. This is the recommended architecture to base your Java web applications on. Model 2 is another name for the Model-View-Controller (MVC) design pattern. In Model 2, there are three main components in an application: the model, the view, and the controller.
Note:-The term Model 2 was first used in the JavaServer Pages Specification version 0.92.
In Model 2, you have one entry point for all pages and usually a servlet or a filter acts as the main controller and JSPs are used as presentation.
Compared to Model 1 applications, Model 2 applications enjoy the following benefits.
• more rapid to build
• easier to test
• easier to maintain
• easier to extend
• more rapid to build
• easier to test
• easier to maintain
• easier to extend
Back to Struts home
No comments:
Post a Comment