JSPBatchCompiler command
The batch compiler validates the syntax of JSPs, translates the JSP pages into Java source files, and compiles the Java source files into Java Servlet class files. The batch compiler also validates tag files and generates their Java implementation classes. Use this function to batch compile the JSPs and thereby enable faster responses to the initial client requests for the JSPs on the production Web server.
The batch compiler can be executed against compressed or expanded EAR and WAR files, as well as enterprise apps and Web modules that have been deployed into WAS. When the target is a deployed enterprise application, the server does not need to be running to execute the batch compiler. If the batch compiler is executed while the target sever is running, the server is not aware of an updated class file and does not load that class file unless the enterprise application is restarted. When the target is a compressed EAR file or WAR file, the batch compiler must expand it before executing.
Processing of Web modules
The batch compiler operates on one Web module at a time. If the target is either an EAR file or an installed enterprise application that contains more than one Web module, the batch compiler operates on each Web module individually.
JSP pages are configured on a Web module basis using web.xml files. Within a Web module, the batch compiler processes one directory at a time.
The batch compiler validates and translates each JSP page individually, and then invokes the Java compiler for the entire group of generated Java sources files in that directory. If one JSP page fails during the Java compilation phase, the Java compiler might not create class files for most or all of the JSP pages that successfully compiled in that directory.
JSP file extensions
The batch compiler uses four things to determine what file extensions it should process:
- Standard JSP file extensions
- *.jsp
- *.jspx
- *.jsw
- *.jsv
- The url-pattern property of the jsp-property-group elements in the deployment descriptor file in Servlet 2.4 Web modules
- The jsp.file.extensions JSP engine configuration parameter (for pre-Servlet 2.4 Web modules)
- The batch compiler configuration parameter jsp.file.extensions
The standard extensions are always used by the batch compiler.
If the Web module contains a Servlet 2.4 deployment descriptor, the batch compiler also processes any url-patterns found within the jsp-config element.
If the batch compiler target contains the JSP engine parameter jsp.file.extensions, then those extensions are also processed.
If the batch compiler configuration parameter jsp.file.extensions is present, the extensions given are also processed and will override the JSP engine configuration parameter jsp.file.extensions.
Give JSP 'fragments' an extension not processed by the batch compiler. Statically-included fragments that do not stand alone generate translation or compilation errors if processed.
The JSP 2.0 Specification suggests that you use the extension .jspf for such files.
Batch compiler command
To execute, run...
WAS_ROOT/bin/JspBatchCompiler.sh|batAn Ant task is also available for executing the batch compiler.
The batch compiler target is the only required parameter...
- -ear.path
- -war.path
- -enterpriseapp.name
JspBatchCompiler.sh -ear.path | -war.path | -enterpriseapp.name <name> [-response.file <filename>] [-webmodule.name <name>] [-filename <jsp name | directory name> [-recurse <true | false>] [-config.root <path>] [-cell.name <name>] [-node.name <name>] [-server.name <name>] [-profileName <name>] [-extractToDir <path>] [-compileToDir <path>] [-compileToWebInf <true | false>] [-compileToWebInf <true | false>] [-compileAfterFailure <true | false>] [-translate <true | false>] [-compile <true | false>] [-removeTempDir <true | false>] [-forceCompilation <true | false>] [-useFullPackageNames <true | false>] [-trackDependencies <true | false>] [-createDebugClassfiles <true | false>] [-keepgenerated <true | false>] [-keepGeneratedclassfiles <true | false>] [-usePageTagPool <true | false>] [-useThreadTagPool <true | false>] [-classloader.parentFirst <true | false>] [-classloader.singleWarClassloader <true | false>] [-additional.classpath <classpath to additional JAR files and classes>] [-verbose <true | false>] [-deprecation <true | false>] [-javaEncoding <encoding> [-jdkSourceLevel <13 | 14 | 15>] [-compilerOptions <space-separated list of java compiler options>] [-useJikes <true | false>] [-jsp.file.extensions <file extensions to process>] [-log.level <SEVERE | WARNING | INFO | CONFIG | FINE | FINER | FINEST | OFF>]For more info, review...
WAS_ROOT/bin/batchcompiler.properties.default
WAS_ROOT/bin/JspCBuild.xmlThe batch compiler is aware of three groups of configuration parameters:
- JSP engine
- Batch compiler response file
- Batch compiler command line
Precedence...
- Command line
- Response file named on the command line
- JSP engine
If parameter not found, default is used (See below).
With one exception, these parameters are not case sensitive; -profileName is case sensitive.
If the values specified contain spaces, add quotation marks around the values.
The batch compiler does not values for equivalent JSP engine parameters. If a JSP page in a deployed Web module is modified and is recompiled by the JSP engine at run time, the JSP engine's configuration parameters will determine the engine's behavior. For example, if we compile a Web module with...
-useFullPackageNames...true also go into the JSP engine and set...
useFullPackageNames...to true to allow the JSP runtime the ability to load the compiled JSP pages. If JSP pages are modified in a deployed Web module, then the engine's parameters should be set to the same values used in batch compilation.
Usage:
- ear.path | war.path | enterpriseapp.name
Full path to a single compressed or expanded EAR or WAR file, or the name of the deployed enterprise application to compile. For example:
- JspBatchCompiler.sh -ear.path /myproject/sampleApp.ear
- JspBatchCompiler.sh -war.path /myWars/examples.war
- JspBatchCompiler.sh -enterpriseapp.name myEnterpriseApp -webmodule.name my.war -filename path/main.jsp
- response.file
Path to a file that contains configuration parameters used by the batch compiler. The response.file is used only if it is given on the command line; it is ignored if it is present in a response file.
To create our own response file...
cd WAS_ROOT/bin
cp batchcompiler.properties.default /myprofile/myfile.propsUsage:
JspBatchCompiler.sh -response.file /myproject/myfile.props
Default : null
- webmodule.name
Specific Web module to compile. If not set, all Web modules in the enterprise application are compiled.
Used only when ear.path or enterpriseapp.name is given. Useful when JSP pages in a specific Web module within a deployed enterprise application need to be regenerated, because all shared library dependencies are picked up.
JspBatchCompiler -enterpriseApp.name sampleApp -webmodule.name myWebModule.war
Default: All Web modules in an EAR file or enterprise application are compiled if this parameter is not given.
- filename
Name of a single JSP file to compile. If not set, all files in the Web module are compiled. Alternatively, if filename is set to the name of a directory, only the JSPs in that directory and that directory's child directories are complied. The name is relative to the context root of the Web module.
Example 1: To compile the file...
/subdir/myJSPs/myTest.jsp...enter...
-filename /subdir/myJSPs/myTest.jspExample 2: To compile all JSPs in /subdir/myJSPs and its child directories, you would enter...
-filename subdir/myJSPsDefault: All JSPs in the Web module are compiled. Entering -filename / is equivalent to the default.
- recurse
Determine whether subdirectories beneath the target directory are processed.
Used only when the filename parameter is given. Set value to false to process only the directory named filename parameter; and not its subdirectories.
JspBatchCompiler.sh -enterpriseApp.name sampleApp -filename /subdir1 -recurse false.
Default: true; All directories beneath the target directory are processed.
- config.root
Location of the WebSpehere Application Server configuration directory.
Used only when enterpriseapp.name is given.
Default:
WAS_ROOT/profiles/profilename/config- cell.name
Name of the cell in which the application is deployed.
Used only when enterpriseapp.name is given.
Default: The default is obtained from the profile script used. The symbolic name of this variable is WAS_CELL.
- node.name
Name of the node in which the application is deployed.
Used only when enterpriseapp.name is given.
Default: The default is obtained from the profile script used. The symbolic name of this variable is WAS_NODE.
- server.name
Name of the server in which the application is deployed.
Used only when enterpriseapp.name is given.
Default: server1
- profileName
Name of the profile you want to use.
Used only when enterpriseapp.name is given.
JspBatchCompiler.sh -enterpriseApp.name sampleApp -profileName AppServer-3
Default: The default profile is used. This is obtained from the file setupCmdLine script in the install_root/bin directory. The symbolic name is DEFAULT_PROFILE_SCRIPT.
- extractToDir
Directory into which predeployed EAR files and WAR files will be extracted before the batch compiler operates on them. This parameter is ignored when enterpriseapp.name is given. The extractToDir parameter is used.
JspBatchCompiler.sh -ear.path /myproject/sampleApp.ear -extractToDir /myTempDir.
Use-case:
You must extract a compressed archive before it is batch compiled. We can also extract an expanded archive to a new directory as well. In both cases, extraction leaves the original archive untouched, which may be useful while development is underway.
Default values
Expanded archive Compressed archive extractToDir supplied The batch compiler extracts the archive to extractToDir before operating on it. If a file or directory of the same name as the archive already exists in the extractToDir, the batch compiler removes the archive completely before extracting that archive. If the batch compiler exits with no errors, it compresses the archive in place in the extractToDir, even if the original EAR file or WAR file was expanded. If errors are encountered during compilation, the EAR file or WAR file is left in the expanded state even if the original EAR file or WAR file was compressed. extractToDir not supplied The batch compiler operates on the EAR file or WAR file in place (does not extract it to another directory) and the archive remains expanded after the batch compiler finishes. The batch compiler extracts the archive to the directory returned by the JVM property "java.io.tmpdir". The rest of the behavior described above, when extractToDir is supplied, is the same in this case.
The default is server1.
- compileToDir
Directory into which JSP pages are translated into Java source files and compiled into class files. This directory can be anywhere on the filesystem, but the batch compiler's default behavior is usually adequate. The batch compiler's behavior when compiling class files is described in the table below
Example:: JspBatchCompiler.sh -enterpriseApp.name sampleApp -compileToDir /myTargetDir
Use-case:
This parameter enables you to generate the Java and class files into a directory outside of the target, which may be useful to compare the newly generated files with their previous versions which remain untouched within the target.
Default values
ear.path or war.path supplied enterpriseApp.name supplied compileToDir not supplied; compileToWebInf not supplied, or is true Class files are compiled into... WEB-INF/classes directoryClass files are compiled into... WEB-INF/classescompileToDir not supplied; compileToWebInf is false Class files are compiled into... WEB-INF/classesClass files are compiled into the WAS temp directory WAS_ROOT/tempcompileToDir is supplied; compileToWebInf not supplied, or is either true or false Class files are compiled into the directory indicated by compileToDir. Class files are compiled into the directory indicated by compileToDir.
- compileToWebInf
Whether the target directory for the compiled JSP class files should be the Web module's WEB-INF/classes directory.
Used only when enterpriseApp.name is given, and it is overridden by compileToDir if compileToDir is given.
The batch compiler's default behavior is to compile to the Web module's WEB-INF/classes directory. The batch compiler's behavior when compiling class files is described in the table above.
JspBatchCompiler -enterpriseApp.name sampleApp -compileToWebInf false.
Use-case:
Set this parameter to false when enterpriseApp.name is supplied and you want the class files to be compiled to the WAS temp directory instead of the Web module's WEB-INF/classes directory. Recommendation: if this parameter is set to false, set forceCompilation to true if there are any JSP class files in the WEB-INF/classes directory.
Default: true; see the table above.
- compileAfterFailure
Specifies whether the JDK JSP batch compiler continues to compile the other JSPs in the current directory if one or more of the JSPs in that directory cannot be complied. Typically when one of the files cannot be compiled, the JSP batch complier skips all of the remaining JSPs in that directory, and starts to compile the files in the next directory.
If we set this parameter to true, also specify the useJDKCompiler parameter and set that parameter to true.
JspBatchCompiler -enterpriseApp.name sampleApp -useJDKCompiler true –compileAfterFailure false.
Use-case:
Set this parameter to true if we want the JSP batch compiler compile the other JSPs in the current directory even if one or more of the JSPs in that directory cannot be complied.
Default: false
- forceCompilation
Whether the batch compiler is forced to recompile all JSP resources regardless or whether the JSP page is outdated.
JspBatchCompiler -ear.path /myproject/sampleApp.ear -forceCompilation true.
Use-case:
Useful when creating an archive for deployment, to make sure all JSP classes are up to date.
Default: false
- useFullPackageNames
Whether the batch compiler generates full package names for JSP classes. The default is to generate all JSP classes in the same package. The JSP engine's class loader knows how to load JSP classes when they are all in the same package. The default has the benefit of generating smaller file-system paths.
Full package names have the benefit of enabling the configuration of precompiled JSP class files as servlets in web.xml without use of the jsp-file attribute, resulting in a single class loader (the Web app's class loader) being used to load all such JSP classes. Similarly, when the JSP engine's configuration attributes useFullPackageNames and disableJspRuntimeCompilation are both true, a single class loader is used to load all JSP classes, even if the JSP pages are not configured as servlets in web.xml.
When useFullPackageNames is set to true, the batch compiler generates a file called generated_web.xml in the Web module's WEB-INF directory.
This file contains servlet configuration information for each JSP page that is successfully translated and compiled. The information can optionally be copied into the Web module's web.xml file so that the JSP pages are loaded as servlets by the Web container.
If a JSP page is configured as a servlet in this way, no reloading of the JSP page is done at run time if the JSP page is modified.
This is because the JSP page is treated as a regular servlet and requests for it do not pass through the JSP engine.
JspBatchCompiler.sh –enterpriseApp.name sampleApp –useFullPackageNames true
Use-case:
Enables JSP classes to be loaded by a single class loader.
Default: false
- removeTempDir
Whether the Web module's temp directory is removed. The batch compiler by default generates JSP class files into a Web module's WEB-INF/classes directory.
JSP class files are generated into the temp directory at run time if a JSP page is modified and JSP reloading is enabled. By batch compiling all the JSP pages in a Web module and also removing the temp directory, disk resources are preserved. We can only use the removeTempDir parameter when -enterpriseApp.name is given.
JspBatchCompiler.sh -enterpriseApp.name sampleApp -removeTempDir true.
Use-case:
Free up disk space by clearing out a Web app's temp directory.
Default: false
- translate
Whether JSP pages are translated and compiled. Set translate to false if we do not want JSP pages to be translated and compiled. Use this option in conjunction with -removeTempDir to tell the batch compiler to remove only the temp directory and to do no further processing.
JspBatchCompiler -enterpriseApp.name sampleApp -translate false -removeTempDir true.
Use-case: Free up disk space by clearing out a Web app's temp directory, without invoking JSP processing.
Default: true
- compile
Whether JSP pages go through the Java compilation phase. Set compile to false if we do not want JSP pages to go through the Java compilation phase.
JspBatchCompiler.sh -enterpriseApp.name sampleApp -compile false
Use-case: If we only want JSP pages to be syntax-checked, set -compile to false. We can set -keepgenerated to true to see the .java files that are generated during the translation phase.
Default: true
- trackDependencies
Whether the batch compiler recompiles a JSP page when any of its dependencies have changed, even if the JSP page itself has not changed. Tracking dependencies incurs a significant runtime performance penalty because the JSP Engine checks the filesystem on every request to a JSP page to see if any of its dependencies have changed. The dependencies tracked by WAS are :
- Files statically included in the JSP page
- Tag files used by the JSP page (excluding tag files that are in JAR files)
- TLD files used by the JSP page (excluding TLD files that are in JAR files)
JspBatchCompiler.sh -ear.path /myproject/sampleApp.ear -trackDependencies true.
Use-case:
Useful in a development environment.
Default: false
- createDebugClassfiles
Whether the batch compiler generates class files that contain SMAP information, as per JSR 45, Debugging support for Other Languages.
JspBatchCompiler -enterpriseApp.name sampleApp -createDebugClassfiles true
Use-case:
Use this parameter when you want to be able to debug JSP pages in the JSR 45-compliant IDE.
Default: false
- keepgenerated
Whether the batch compiler saves or erases the generated Java source files created during the translation phase.
If set to true, WAS saves the generated .java files used for compilation on the server. By default, this argument is set to false and the .java files are erased after the class files have compiled.
JspBatchCompiler -ear.path /myproject/sampleApp.ear -keepgenerated true
Use-case:
Use this parameter when you want to review the Java code generated by the batch compiler.
Default: false
- keepGeneratedclassfiles
Whether the batch compiler saves or erases the class files generated during the compilation of Java source files.
JspBatchCompiler -ear.path /myproject/sampleApp.ear -keepGeneratedclassfiles false -keepgenerated false
Use-case:
Set this parameter to false if we only want to see if there are any translation or compilation errors in the JSP pages. If paired with -keepgenerated false, this parameter results in all generated files being removed before the batch compiler completes.
Default: true
- usePageTagPool
Enables or disables the reuse of custom tag handlers on an individual JSP page basis.
JspBatchCompiler -ear.path /myproject/sampleApp.ear -usePageTagPool true
Use-case:
Use this parameter to enable JSP-page-based reuse of tag handlers.
Default: false
- useThreadTagPool
Enables or disables the reuse of custom tag handlers on a per request thread basis per Web module.
JspBatchCompiler.sh -ear.path /myproject/sampleApp.ear -useThreadTagPool true
Use-case:
Use this parameter to enable Web module-based reuse of tag handlers.
Default: false
- classloader.parentFirst
Search order for loading classes by instructing the batch compiler to search the parent class loader prior to application class loader. This parameter is only used when ear.path or enterpriseApp.name is given.
JspBatchCompiler -ear.path /myproject/sampleApp.ear -classloader.parentFirst false
Use-case:
Set this parameter to false when the Web module contains a JAR file that is also found in the server lib directory, and you want the Web module's JAR file to be picked up first.
Default: true
- classloader.singleWarClassloader
Whether to use one class loader per EAR file or one class loader per WAR file.
Used only when ear.path or enterpriseApp.name is given.
JspBatchCompiler -ear.path /myproject/sampleApp.ear -classloader.singleWarClassloader true
Use-case:
Set this parameter to true when a Web module depends on JAR files and classes in another Web module in the same enterprise application.
Default: false; One class loader is created per WAR file with no visibility of classes in other Web modules.
- additional.classpath
Specifies additional class path entries to be used when parsing and compiling JSP pages. This parameter is used only when war.path is given. When war.path is the target, WebSphere Shared Libraries are not picked up by the batch compiler. Therefore, if the WAR file relies on, for example, a JAR file configured in WAS as a shared library, then use this option to point to that JAR file. In addition, if we give war.path and also use the -extractToDir parameter, then any JAR files that are in the WAR file's manifest class-path is not added to the class path (since the WAR file has now been extracted by itself outside the EAR file in which it resides). Use -additional.classpath in this case to point to the necessary JAR files. Add the full path to needed resources, separated by the system-dependent path separator.
JspBatchCompiler.sh -war.path /myproject/examples.war -additional.classpath /myJars/someJar.jar;/myClasses
Use-case:
Use this parameter to add to the class path JAR files and classes outside of the WAR file. At run time, these same JAR files and classes have to be made available through the standard WAS configuration mechanisms.
Default: null
- verbose
Whether the batch compiler should generate verbose output while compiling the generated sources.
JspBatchCompiler.sh -war.path /myproject/examples.war -verbose true
Use-case:
Set this parameter to true when you want to see Java compiler class loading and other messages.
Default: false
- deprecation
Compiler should generate deprecation warnings while compiling the generated sources.
JspBatchCompiler.sh -war.path /myproject/examples.war -deprecation true
Use-case:
Set this parameter to true when you want to see Java compiler deprecation messages.
Default: false
- javaEncoding
Encoding that will be used when the .java file is generated, and when it is compiled by the Java compiler. When -javaEncoding is set, that encoding is passed to the java compiler via the -encoding argument.
Note that encoding is not supported by Jikes.
JspBatchCompiler -war.path /myproject/examples.war -javaEncoding Shift-JIS
Use-case:
Set this parameter when the page encoding of the JSP pages is not UTF-8 compatible.
Default value: UTF-8.
- jdkSourceLevel
This is a new JSP engine parameter which was introduced in WAS version 6.1 to support JDK 5. This parameter should be used instead of the compileWithAssert parameter, although compile WithAssert still works in version 6.1. The default value for this parameter is 13. This parameter requires regeneration of Java source.
The following are jdkSourceLevel paramater values:
- 13 (default) - This value will disable all new language features of JDK 1.4 and JDK 5.0.
- 14 - This value will enable the use of the assertion facility and will disable all new language features of JDK 5.0.
- 15 - This value will enable the use of the assertion facility and all new language features of JDK 5.0.
JspBatchCompiler.sh -war.path /myproject/examples.war -jdkSourceLevel 14
Use-case:
Set this parameter when you want to enable or disable the language features of JDK 1.4 and JDK 5.0
Default value: 13
- compilerOptions
List of strings to be passed on the Java compiler command. This is a space-separated list of the form "arg1 arg2 argn".
JspBatchCompiler.sh -war.path /myproject/examples.war -compilerOptions " -bootclasspath <path>"
Use-case:
Use this parameter if we need Java compiler arguments other than verbose, deprecation and Assert facility support.
Default: null
- useJikes
Whether Jikes should be used for compiling Java sources. NOTE: Jikes is not shipped with WAS.
JspBatchCompiler.sh -ear.path /myproject/sampleApp.ear -useJikes true
Use-case:
Set this parameter to true in order for the batch compiler to use Jikes as the Java compiler.
Default value: false
- jsp.file.extensions
Semicolon- or colon-separated list of file extensions to be processed by the batch compiler...
*.ext1;*.ext2:*.extnNot necessary for Servlet 2.4 Web apps because the url-pattern property of the jsp-property-group elements in the deployment descriptor can be used to identify extensions that should be treated as JSP pages.
JspBatchCompiler -enterpriseApp.name sampleApp -jsp.file.extensions *jspz;*.jspt
Use-case:
Use this parameter to add additional extensions to the be processed by the batch compiler.
Default: null. See section, "JSP file extensions", in this topic for additional information.
- log.level
Level of logging that is directed to the console during batch compilation.
SEVERE | WARNING | INFO | CONFIG | FINE | FINER | FINEST | OFF
JspBatchCompiler -enterpriseApp.name sampleApp -log.level FINEST
Use-case:
Set this parameter higher or lower to control logging output. FINEST generates the most output useful for debugging.
Default: CONFIG
Related concepts
JSPs
Related tasks
Set JSP engine parameters
Related
Batch compiler ant task
Web apps: Links