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.