What did the server do inside the JSP when compiling it?

Source: Internet
Author: User
Tags garbage collection client
js| Compilation | Server author/Source: Blueski Compilation

 

The JSP file is converted into a servlet by the JSP engine (JSP engine) when the JSP first obtains the request, whether the request is from a client browser or a servlet on the server. And the engine itself is a servlet, in JSWDK, it's jspservlet.

If a JSP file is found to have any syntax errors at compile time, the conversion process is interrupted and an error message is sent to the client, and if the compilation succeeds, the resulting servlet code is compiled, and the servlet is loaded into memory by the JSP engine. The JSP engine also requests the execution of the Jspinit () method and initializes the servlet. The Jspinit () method is only requested once in the lifecycle of the servlet. The Jspservice () method is then called to handle the client's request and reply operations. For all subsequent requests for the JSP file, the server checks to see if the. jsp file has been modified since it was last accessed. If there is no modification, the request will be addressed to the Jspservice () method of the servlet that is still in memory in a simultaneous manner. Note that because the servlet is always in memory, the response is very fast.
If the. jsp file is modified, the server will automatically recompile the file and replace the result with the in-memory servlet and continue the process described above.


Although JSP is highly efficient, there are some minor delays in the first invocation due to the need for conversion and compilation. Also, if, at any time, the JSP engine removes the servlet from memory in some uncertain fashion due to insufficient system resources. When this occurs, the Jspdestroy () method is invoked first, and then the servlet instance is tagged to the garbage collection process.

 

Related content:

JSP precompiled Compiler:
The Jakarata Tomcat3.1 JSP server (http://jakarta.apache.org) contains a JSP compiler (JSPC) that can be precompiled to define a file directory for a Web application. You can also specify a specific JSP file to compile.
In addition, Oracle also has JSPC

Related Article

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.