Home  >  Article  >  Java  >  What is the execution process of jsp

What is the execution process of jsp

(*-*)浩
(*-*)浩Original
2019-05-20 18:07:4923632browse

When the jsp page is accessed for the first time, a request will be made to a servlet container (tomcat, etc.). The servlet container must first convert the jsp page into servlet code (.java), then compile it into a .class file and then call it. When visiting the jsp page again, skip the translation and compilation process and directly call

What is the execution process of jsp

The execution process of the Web container to process the JSP file request mainly includes The following 4 parts:
1. The client issues a Request request
2. JSP Container translates JSP into Servlet source code
3. After compiling the generated Servlet source code, and Load into memory for execution
4. Send the result Response to the client

Many people will think that the execution performance of JSP will be very different from that of Servlet. In fact, the difference in execution performance is only in the first time implement. Because JSP will be compiled into a Servlet class file, that is, .class, after it is executed for the first time. When the execution is called repeatedly, the Servlet generated for the first time will be executed directly without recompiling JSP into Servelt. Therefore, in addition to the first compilation taking a long time, the execution speed of JSP and Servlet is almost the same.

When executing a JSP web page, can usually be divided into two periods:

Translation Time and Request Time

Translation period: JSP web pages are transferred into Servlet classes.
Request period: After the Servlet class is executed, the response result is sent to the client.

Two things were done during the translation period:
Translation period: Transfer the JSP web page to Servlet source code.java.
Compilation period: Compile the Servlet source code.java Into Servlet class.class.

When the JSP webpage is executing, the JSP Container will do the checking work. If it is found that the JSP webpage has been updated and modified, the JSP Container will compile the JSP into a Servlet again; if the JSP has not been updated. , directly execute the Servlet generated previously.

Related learning recommendations: java basic tutorial

The above is the detailed content of What is the execution process of jsp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does jspuserBean do?Next article:What does jspuserBean do?