Relationship and difference between JSP model1 and model2 -- [DRP]

Source: Internet
Author: User

Relationship and difference between JSP model1 and model2 -- [DRP]

JSP Model1 and Model2 are two ways to create an Application Using JSP technology.

The architecture diagram of Model1 is as follows:

1. First, the web browser sends a Request to the JSP page to obtain the page parameters.

2. operate the business logic through JavaBean.

3. Operate the application data source and return data.

4. render the JSP page through Response.

Advantages:Simple architecture, suitable for small project development. Basically, two layers of code can be done, JSP + persistent layer.

Disadvantages:The JSP page controls the code displayed on the page and the Java code that interacts with the background business logic. The roles and responsibilities are not uniform, and the page load is heavy, which affects the page running speed. In addition, it is not convenient for later maintenance.

The architecture diagram of Model2 is as follows:

The difference between Model2 and Model1 is:

1.Model1 is the JSP responsible for business logic + page display, Model2 uses servlet and JSP collaboration, JSP is responsible for page display, servlet is responsible for business logic, the page and business are decoupled and, make the development and maintenance of the entire front-end more flexible.

Specific responsibilities:

JavaBean (Model), Model, Main Responsibilities 1. Business Logic 2. Save data status

JSP (View), View, main responsibilities: 1. Page display

Servlet (Controller), Controller, main responsibilities: 1. Get form data 2. Call business logic 3. Render page

Advantages:Clear responsibilities, suitable for large projects

Disadvantages:Too many layers, not suitable for development of small projects

Summary

Model2 is an evolutionary version of Model1, or an extended version. The applications of the two are different. A large project is a small project. Just like a company, if the company wants to expand its scale, it must have a single responsibility, so that it will not lead to unclear personnel responsibilities, inefficiency, and waste of resources.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.