Current location - Loan Platform Complete Network - Big data management - What is the relationship between Java and JSP in Javaweb technology?
What is the relationship between Java and JSP in Javaweb technology?
JSP is the core component of traditional JavaWeb development, and its main function is to build views.

There are servlets and JavaBeans in the traditional JavaWeb development scheme. Servlets acts as the controller and JavaBeans acts as the model, which is the classic Model2 solution.

What can JSP do? JSP can do two things, one is presentation, and the other is business processing. The traditional Model 1 scheme is realized by JSP+JavaBean (this scheme was nearly 20 years ago). Simply put, JSP can do both html and service Servlet. Although some people suggest that JSP only does the things of presentation layer, JSP can completely embed executable Java code, that is, it can integrate presentation layer logic and business logic. Because of this, JSP is rarely seen in large-scale projects at present.

The request flow of traditional scheme is that after the user's request is sent to the server, the Servlet receives the user's request (data extraction, data verification, function matching, etc.). ), then call JavaBean's business method to complete the business processing, and finally jump to JSP page, which presents the results.

At present, this method can only be seen in some small-scale Web development, and JSP is rarely used in some large-scale Web development schemes for the following reasons:

First of all, JSP is essentially a Servlet. JSP is to be converted into Servlet for execution, which requires that JSP must be in WebContainer, and WebContainer is often responsible for the processing of business logic, which has a great impact on performance.

Second, the coupling of dynamic and static resources. This is also one of the main reasons why JSP has been criticized. The early stage is an advantage, and the later stage is the biggest disadvantage.

Third, JSP has many contents and is slow to load. Front-end engineers also need to understand the use of various JSP tags, which are often error-prone.

At present, the large-scale Web development scheme is that the front-end access directly reaches the html page, and the html page is processed by a separate server (such as Nginx), which improves the efficiency of access, and then the html page initiates an interface call. This can complete the static and dynamic classification, improve the development efficiency and improve the stability of the server.

Of course, there is no harm for beginners to learn the use of JSP. After all, a large number of projects still use JSP as the presentation end. If the number of concurrent requests of the project is not high, it is very convenient to adopt JSP.

I have been using Java programming for many years and am currently leading a Java development team (mobile Internet, big data direction). I will write some articles about Java development in the headlines one after another, and interested friends can