标签:des style http io ar os sp for java
Web Server provides the following ways of compiling JSP 2.1-compliant source files into servlets:
JSP are automatically compiled at runtime.
The jspc command-line tool, described in this section, enables you to precompile JSPs at the command line.
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 JSP Element.
The jspc command-line tool is located under install_dir/bin. The format of the jspc command is as follows:
jspc [options] file_specifier
The following table shows what file_specifier can contain in the jspc command.
Table 5–1 File Specifiers for the jspc Command
File Specifier |
Description |
---|---|
files |
One or more JSP files to be compiled. |
-webappdir |
A directory containing a web application. All JSPs in the directory and its subdirectories are compiled. You cannot specify a WAR, JAR, or ZIP file. You must first extract such files to an open directory structure. |
The following table shows the basic options for the jspc command.
Option |
Description |
---|---|
-help |
Enables quiet mode (same as -v0). Only fatal error messages are displayed. |
-v |
Verbose mode. |
-d dir |
Specifies the output directory for the compiled JSPs. Package directories are automatically generated based on the directories containing the uncompiled JSPs. The default top-level directory is the directory from which jspc is invoked. |
-l |
Specifies the name of the JSP on failure. |
-s |
Specifies the name of the JSP on success. |
-p name |
Specifies the name of the target package for all specified JSPs, overriding the default package generation performed by the -d option. |
-c name |
Specifies the target class name of the first JSP compiled. Subsequent JSPs are unaffected. |
-mapped |
Generates separate write() calls for each HTML line in the JSP. |
die(#) |
Generates an error return code (#) on fatal errors (default 1). |
-uribase dir |
Specifies the URI directory to which compilations are relative. Applies only to explicitly declared JSP files. This path is the location of each JSP file relative to the uriroot. If this location cannot be determined, the default is /. |
-uriroot dir |
A directory containing a web application. All JSPs in the directory and its subdirectories are compiled. You cannot specify a WAR, JAR, or ZIP file. You must first extract such files to an open directory structure. |
-compile |
Compiles the generated servlets. |
-genclass |
Generates class files in addition to Java files. |
-webinc file |
Creates a partial servlet mappings in the file. |
-web.xml file |
Creates a complete web.xml structure in the file. |
-ieplugin clsid |
Java Plug-in classid for Internet Explorer. |
classpath path |
Overrides the java.class.path system property |
xpoweredBy |
Add the X-Powered-By response header. |
-trimSpaces |
Trims spaces in text templates between actions and directives. |
-smap |
Generates SMAP info for JSR 45 debugging. |
-dumpsmap |
Dumps SMAP info for JSR45 debugging into a file. |
-compilerSourceVMrelease |
Provides source compatibility with specified JDKTM release. |
-compilerTargetVMrelease |
Generates class files for specified VM version. |
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.
原文地址:https://docs.oracle.com/cd/E19146-01/821-0790/abxcc/index.html
Compiling JSPs Using the Command-Line Compiler---官方
标签:des style http io ar os sp for java
原文地址:http://www.cnblogs.com/davidwang456/p/4156451.html