Tomcat performance adjustment (4)

xiaoxiao2021-03-13  203

3. Accelerate JSP compilation speed

When an JSP file is accessed for the first time, it will be converted to the Java Serverlet source, followed by the Java bytecode. You can control which compiler to use, by default, Tomcat uses the compiler that uses the command line Javac. You can also use a faster compiler, but here we will introduce how to optimize them.

Another way is to use all implementations to use JSP pages, but use some different Java template engine variables. Obviously this is a big decision, but it is true that at least this approach is to study. If you want to learn more about Tomcat, you can refer to Jason Hunter and William Crawford book (published by O'Reilly).

A popular and free Jikes compiler can be used in Tomcat 4.0. The JIKES compiler speeds due to Sun's Java compiler. First include Jikes (accessible http: //oss.software.ibm.com/pub/jikes get more information), then set the JAR files you need to include the system runtime in the environment variable. After installing jikes, you need to set up the JSP compile Servlet Use Jikes, you need to modify the value of jspcompilerplugin in the web.xml file:

jsp org.apache.jasper.servlet.jspservlet LogverbosityleLvel Warning jspcompilerplugin org.apache.jasper.compiler. Jikesjavacompiler org.apache.catalina.jsp_classpath -> Classpath < / param-name> /usr/local/jdk1.3.1-linux/jre/lib/java/servletapi/servlet.jar < / init-param> 3

In Tomcat 4.1 (or higher), the compilation of JSP is executed directly by the ANT controller included in Tomcat. This sounds a little strange, but this is part of ANT intention to use, and an API document guides developers using Ant without launching a new JVM. This is a major advantage in Java development using Ant. In addition, this also means that you can now use any Javac support in Ant, here there is a Javac page list about the APACHE ANT User Manual. It is easy to use because you only need to define a name "Compiler" in the element, and there is a compiler name supported in Value. Examples are as follows: jsp org.apache.jasper.servlet.jspservlet logverbositylevel Warning Compiler jikes 3

ANT available compiler

The compiler classic javac1.1 alias name calling, javac1.2 Standard JDK 1.1 / 1.2 compiler modern javac1.3, javac1.4 Standard JDK 1.3 / 1.4 compiler jikes The Jikes compiler JVC Microsoft Microsoft command-line compiler from the Microsoft SDK for Java / Visual J KJC The Kopi Compiler GCJ THE GCJ Compiler (Included As Part of GCC) SJ Symantec Symantec's Java Compiler Extjavac Runs Either The Modern Or Classic Compiler In a JVM of ITS OWN

Since the JSP page has been compiled in the first time, you may want to compile it immediately after updating the new JSP page. In fact, this process can be automated because it can be confirmed that the new JSP page is the same in the production server and the running effect on the test server.

转载请注明原文地址:https://www.9cbs.com/read-129028.html

New Post(0)