Detailed JSP execution process

The concept of JSP

JSP stands for Java Server Pages, which contains html tags, css styles, JavaScript scripts and Java code.
Note: <%=currentTime%> cannot have spaces before the equal sign and %.

Implementation process

When a user accesses a JSP page on Tomcat through a browser, the web application server uses the JSP engine to translate (Java file), compile (.class file) and execute the page, and then return the execution result (static page code) to the client At the end of the browser, the results returned by the browser interpretation and execution are presented to the user, as shown in the following figure:

Translation stage : When the Web application server for the first time upon receipt of the JSP page request, the JSP page that will translate to translate the page jsp code into Java source code

Compilation stage : Java source code is not runnable, so after the compilation stage, the web application server will compile the Java source file into an executable bytecode file and load it into the memory

Execution stage : The web application server will execute the compiled Java bytecode file, get the result of the request processing, and feed the generated result back to the client browser.

When a JSP page is accessed for the first time, it will be translated, compiled and executed; when the JSP page is accessed again, if the JSP content has not been modified, there is no need to go through the process of translation and compilation, and it will be executed directly. can.

Doing so can significantly improve the performance of the application server, effectively reduce the response time from the user sending a request to the server to receiving the feedback page, and improve the user experience. It also explains why when a JSP page is accessed for the first time, its response speed is relatively slow.

Note: JSP translation, compilation and execution operations are all performed on the server side. What is returned to the client browser is the HTML code after the server side executes the JSP corresponding bytecode file, so the client can browse as long as there is a browser. JSP page.

 

Guess you like

Origin blog.csdn.net/m0_46383618/article/details/107526785