JSP pre-compile problem

Source: Internet
Author: User
Tags command line implement version
js| Compiling | The problem is the easiest way to do JSP precompilation so far (the "flick-a-switch" approach), and he has many points to the point where there are no meaningful flaws. If an error occurs during the compilation of a JSP or when it is deployed (or redeployed), the precompilation of the WEB application will be paused at the exception. In addition, if there are many JSP files in a particular Web application, declarative precompilation significantly affects deployment time, blocking deployment until all files are compiled. For large applications, when hundreds of JSP files appear to be executed with declarative precompilation, this deployment time tends to be measured in minutes (in some cases 10-15 minutes, others may be longer). Imagine starting a server instance, going into the deployment state within a specific Web application cycle, using declarative precompilation activation. If there are a lot of JSP files in the application and deployment, close to completion has spent a lot of time, during the compilation of an exception to throw a sudden failure, of course, will cause frustration. While it may seem convenient at first, declarative compilation poses a significant risk to production system management and should be used after careful consideration.

Pre-compiling of program mode

The most reliable way to precompile a JSP under WLS is to use the Java command line, WEBLOGIC.JSPC, located in Weblogic.jar file under WLS installed Lib directory. This tool allows developers to compile the required JSP files during the development phase and when resolving compile-time issues before deployment. It also provides an administrator with the ability to implement JSP precompilation for production systems. The main benefits of this usage are:

Files can be precompiled once and can be deployed multiple times. (This is not affected by the reuse of the server instance)

Compile-time exceptions can be resolved in advance without affecting deployment.

Classes can be deployed through clusters.

The disadvantage of using WEBLOGIC.JSPC is that it requires manual intervention, and it is developed and must be rerun when the JSP file becomes obsolete. However, given the discussion of the previous two methods, we can hardly regard this inconvenience as a disadvantage of the method, so it is recommended as the most reliable and flexible mechanism to implement JSP precompilation.

Execute WEBLOGIC.JSPC

In order to use WEBLOGIC.JSPC more effectively, you must first understand its usage and syntax. In this article we will take advantage of the functionality of the WLS6.1 SP2 tool. Note: The syntax and best practices given below should be applied to all versions of WLS 6.1 and to the new WLS 7.0.

In order to invoke the command line JSP compiler (WEBLOGIC.JSPC), you must determine the following:

The PATH environment variable must contain a binary directory of the j2se1.3 package installed on your machine (for example,/opt/j2se/1.3.1/sdk/bin or C:sunsoftj2se1.3.1sdkin) to obtain support for the JVM runtime. If you plan to use Javac as your JSP compiled Java compiler, make sure that path contains a binary directory of all Java 1.3 software Development Kits (SDK), and not only the JRE (Java Runtime Engine,java runtime engine), Because there are no compilers associated with the JRE. If you plan to use a compiler instead of javac (for example, Jikes), be sure to include the correct directory in the path for that compiler.

Set the Java system classpath to contain Weblogic.jar files from the WLS 6.1 SP2 installation directory, by default established in the Product Library directory (for example,/opt/bea/wlserver6.1/lib/weblogic.jar or C: Eawlserv-er6.1libweblogic.jar). Also, make sure that the reference class (Jar or class file) you may need in the JSP compilation phase is in your classpath as well.

Before you perform WEBLOGIC.JSPC for the first time, you need to test that your command-line configuration is configured as described above. It can be done by simply running a WLS version check and using the command "Java weblogic.version", which should return the following:

Which should return the following:
WebLogic Server 6.1 SP2 12/18/2001 11:13:46
#154529
WebLogic XML Module 6.1 SP2 12/18/2001
11:28:02 #154529

If your output is not the same as the one above (corresponds to the version you are running), re-access the path and CLASSPATH variables and set it to your current command-line environment before you precompile the JSP.

The general WEBLOGIC.JSPC syntax is given below:

Java WEBLOGIC.JSPC [options] <jsp files&gt ....

In a single invocation of a compiler, the JSP compiler can compile a JSP file or a set of JSP files by default, and the compiler can work in different ways by setting command-line options. An example is given below:

Java
Weblogic.jspc
-webapp MyWebApp
-compiler Javac
-compileflags "-G"
-classpath/u/apps/dist/src/lib.jar
-D.
-package com.slackwerks.mywebapp.jsp
-commentary
-keepgenerated
-K
mywebappindex.jsp

This article only cites an example, if you want to know more about how WEBLOGIC.JSPC can be used and managed in your environment, see WWW.SLACKWERKS.COM/WLDJ, we provide a discussion of the full set of work options, the meaning of use, and related issues.

Conclusion

Although there are many problems about JSP precompilation, a lot of ways can be solved. However, given the advantages and disadvantages mentioned above, it should be easier to see how the program via WEBLOGIC.JSPC is a flexible option to overcome the inherent drawbacks of JSP. Early in the development phase, familiarity with the tool will improve the management and performance of applications during production.
 





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.