Compiling JSPS using the command line compiler – Official

Web Server provides the following ways of compiling JSP 2.1-compliant source files into servlets:

You must disable dynamic reloading of JSP when deploying a web application archive that has precompiled JSP without the correspondingjsp source files. To do this,set the reload-interval property to -1 in the jsp-config element of the sun-web. xml file. For more information,see .

The jspc command-line tool is located under install_ dir/bin. The format of the jspc command is as follows:

The following table shows what file_ specifier can contain in the jspc command.

Table 5–1 File Specifiers for the jspc Command

The following table shows the basic options for the jspc command.

Table 5–2 Basic jspc Options

For example,this command compiles the hello JSP file and writes the compiled JSP under hellodir:

jspc -d hellodir -genclass hello.jsp

This command compiles all of the JSP files in the web application under webappdir into class files under jspclassdir:

jspc -d jspclassdir -genclass -webapp webappdir

To use either of these precompiled JSPs in a web application,put the classes under hellodir or jspclassdir into a JAR file,place the JAR file under WEB-INF/lib,and set the reload-interval property to -1 in the sun-web. xml file.

When a JSP is compiled,a package is created for it. The package name starts with jspc. For example,the generated package name for~/SOURCE/JSP/myjsps/hello. jsp is precompiled as jspc -webapp ~/SOURCE -d ~/test1/test2/test3. The generated servlet is located in ~/test1/test2/test3/org/apache/jsp/JSP/myjsps/hello_ jsp. java and defined in org. apache. jsp. JSP. myjsps. The path for hello. jsp is derived from the directory in which the JSP is located. In another example,the same hello. jsp is precompiled using the —p option,and is precompiled as jspc -webapp ~/SOURCE -d ~/test1/test2/test3 -p app1. app2. app3. The generated servlet is located in~/test1/test2/test3/app1/app2/app3/JSP/myjsps/hello_ jsp. java and defined inside package app1. app2. app3. JSP. myjsps. Note that the package specified with the -p option (app1.app2.app3) overrides the standard org. apache. jsp but does not affect the package derived from the directory in which the JSP is located. Also,note that the -d option does not affect on the generated package name.

For information about the various JSP configuration parameters you can use,see the section jsp-config Element. The JSP compiler uses the default values for parameters that are not included in the file.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>