The batch compiler validates the syntax of JSP pages, 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 your JSP files and thereby enable faster responses to the initial client requests for the JSP files on your production Web server.
The batch compiler can be executed against compressed or expanded enterprise archive (EAR) files and Web application archive (WAR) files, as well as enterprise applications and
Web modules that have been deployed into WebSphere Application Server. 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. This is done because JSP pages are configured on a Web module basis, through the Web module's web.xml deployment descriptor file. Within a Web module, the batch compiler processes one directory at a time. It 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 extensionsThe batch compiler uses four things to determine what file extensions it should process:
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 configuration 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 .
It is a good idea to give JSP 'fragments' an extension that is 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
Both a Windows batch file, JspBatchCompiler.bat and Unix shell script JspBatchCompiler.sh for running the batch compiler from the command line are found in the {WAS_ROOT}/bin directory. An Ant task is also available for executing the batch compiler using Ant. See the topic, Batch Compiler Ant Task for additional information. The batch compiler target is the only required parameter. The target is one of -ear.path, -war.path or -enterpriseapp.name.
JspBatchCompiler -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>] [-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 >] [-jspCompileClasspath <classpath to Websphere Application Server public API JAR files; or no value at all >] [-verbose <true | false>] [-deprecation <true | false>] [-javaEncoding <encoding> [-compileWithAssert <true | false>] [-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 >] *** See batchcompiler.properties.default in WAS_ROOT/bin for more information. *** *** See JspCBuild.xml in WAS_ROOT/bin for information about the public WebSphere Ant task JspC. ***The batch compiler is aware of three groups of configuration parameters:
See the topic, JSP engine configuration parameters.
These are the parameters that are found in a batch compiler response file. See -response.file, below.
These are the parameters entered on the command line when running the batch compiler.
If a configuration parameter is not found among these three groups, then a default value is used. The default values for the configuration parameters are given below along with the description of the parameters.
With one exception, these parameters are not case sensitive; -profileName is case sensitive. If the values specified for these arguments are comprised of two or more words separated by spaces, add quotation marks around the values.
The batch compiler does not create, or set the values of, equivalent JSP engine parameters. This means that if a JSP page in a deployed Web module is modified and is recompiled by the JSP engine at runtime, the JSP engine's configuration parameters will determine the engine's behavior. For example, if you use the batch compiler to compile a Web module and you use the -useFullPackageNames true option, the JSP files will be compiled to support that option. But the JSP engine parameter useFullPackageNames must also be set to true in order for the JSP Runtime to be able 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.
To use the JSP batch compiler, enter the following command on a single line at an operating system command prompt: where:
The 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. In a default installation, the template response file, batchcompiler.properties.default, is found in {WAS_ROOT}/bin . Copy this template to create your own response files containing defaults for the parameters in which you are interested. All the required and optional parameters (except response.file) can be configured in a response file.
Example: JspBatchCompiler -response.file c:\myproject\batchc.props
Default : null
Represents the name of the specific Web module that you want to batch compile. If this argument is not set, all Web modules in the enterprise application are compiled. This parameter is used only when ear.path or enterpriseapp.name is given. This parameter is useful when JSP pages in a specific Web module within a deployed enterprise application need to be regenerated, because all Shared Library dependencies will be picked up.
Example: 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.
Represents the name of a single JSP file that you want to compile. If this argument is not set, all files in the Web module are compiled. Alternatively, if filename is set to the name of a directory, only the JSP files 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: If you want to compile the file, myTest.jsp, and it is found in /subdir/myJSPs, you would enter -filename /subdir/myJSPs/myTest.jsp.
Example 2: If you want to compile all JSP files in /subdir/myJSPs and its child directories, you would enter -filename subdir/myJSPs.
Default: All JSP files in the Web module are compiled. Entering -filename / is equivalent to the default.
Determines whether subdirectories beneath the target directory are processed. This parameter is used only when the filename parameter is given. Set value to false to process only the directory named filename parameter; and not its subdirectories.
Example: JspBatchCompiler -enterpriseApp.name sampleApp -filename /subdir1 -recurse false.
Default: true; All directories beneath the target directory are processed.
The location of the WebSpehere Application Server configuration directory. This parameter is used only when enterpriseapp.name is given.
Default: {WAS_ROOT}/profiles/profilename/config
The name of the cell in which the application is deployed. This parameter is used only when enterpriseapp.name is given.
Default: The default is obtained from the profile script that is used. The symbolic name of this variable is WAS_CELL.
The name of the node in which the application is deployed. This parameter is used only when enterpriseapp.name is given.
Default: The default is obtained from the profile script that is used. The symbolic name of this variable is WAS_NODE.
Represents the name of the server in which the application is deployed. This parameter is used only when enterpriseapp.name is given.
Default: server1
The name of the profile you want to use. This parameter is used only when enterpriseapp.name is given.
Example: JspBatchCompiler -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.
The directory into which predeployed enterprise archive (EAR) files and Web application archive (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 as described in the table below.
Example: JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -extractToDir c:\myTempDir.
Use-case: You must extract a compressed archive before it is batch compiled. You 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.
The 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 -enterpriseApp.name sampleApp -compileToDir c:\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 if you want 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 | The class files are compiled into the Web module's WEB-INF/classes directory | The class files are compiled into the Web module's WEB-INF/classes directory. |
compileToDir not supplied; compileToWebInf is false | The class files are compiled into the Web module's WEB-INF/classes directory. | The class files are compiled into the WebSphere temp directory (usually {WAS_ROOT}/temp). |
compileToDir is supplied; compileToWebInf not supplied, or is either true or false | The class files are compiled into the directory indicated by compileToDir. | The class files are compiled into the directory indicated by compileToDir. |
Whether the target directory for the compiled JSP class files should be the Web module's WEB-INF/classes directory. This parameter is 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.
Example: 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 WebSphere Application Server 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.
Whether the batch compiler is forced to recompile all JSP resources regardless or whether the JSP page is outdated.
Example : JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -forceCompilation true.
Use-case: Especially useful when creating an archive for deployment, to make sure all JSP classes are up to date.
Default: false
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 the web.xml file without use of the jsp-file attribute, resulting in a single class loader (the Web application'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 the web.xml file.
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. Note that if a JSP page is configured as a servlet in this way, no reloading of the JSP page is done at runtime 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.
Example: JspBatchCompiler —enterpriseApp.name sampleApp —useFullPackageNames true
Use-case: Enables JSP classes to be loaded by a single class loader.
Default: false
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 runtime 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. You can only use the removeTempDir parameter when -enterpriseApp.name is given.
Example: JspBatchCompiler -enterpriseApp.name sampleApp -removeTempDir true.
Use-case: Free up disk space by clearing out a Web application's temp directory.
Default: false
Whether JSP pages are translated and compiled. Set translate to false if you do not want JSP pages to be translated and compiled. You must use this option in conjunction with -removeTempDir to tell the batch compiler to remove only the temp directory and to do no further processing.
Example: JspBatchCompiler -enterpriseApp.name sampleApp -translate false -removeTempDir true.
Use-case: Free up disk space by clearing out a Web application's temp directory, without invoking JSP processing.
Default: true
Whether JSP pages go through the Java compilation phase. Set compile to false if you do not want JSP pages to go through the Java compilation phase.
Example: JspBatchCompiler -enterpriseApp.name sampleApp -compile false
Use-case: If you only want JSP pages to be syntax-checked, set -compile to false. You can set -keepgenerated to true if you want to see the .java files that are generated during the translation phase.
Default: true
Example: JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -trackDependencies true.
Use-case: Useful in a development environment.
Default: false
Whether the batch compiler generates class files that contain SMAP information, as per JSR 45, Debugging support for Other Languages .
Example: JspBatchCompiler -enterpriseApp.name sampleApp -createDebugClassfiles true
Use-case: Use this parameter when you want to be able to debug JSP pages in your JSR 45-compliant IDE.
Default: false
Whether the batch compiler saves or erases the generated Java source files created during the translation phase.
If set to true, WebSphere Application Server saves the generated .java files used for compilation on your server. By default, this argument is set to false and the .java files are erased after the class files have compiled.
Example: JspBatchCompiler -ear.path c:\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
Whether the batch compiler saves or erases the class files generated during the compilation of Java source files.
Example: JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -keepGeneratedclassfiles false -keepgenerated false
Use-case: Set this parameter to false if you only want to see if there are any translation or compilation errors in your JSP pages. If paired with -keepgenerated false, this parameter results in all generated files being removed before the batch compiler completes.
Default: true
Enables or disables the reuse of custom tag handlers on an individual JSP page basis.
Example: JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -usePageTagPool true
Use-case: Use this parameter to enable JSP-page-based reuse of tag handlers.
Default: false
Enables or disables the reuse of custom tag handlers on a per request thread basis per Web module.
Example: JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -useThreadTagPool true
Use-case: Use this parameter to enable Web module-based reuse of tag handlers.
Default: false
The 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.
Example: JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -classloader.parentFirst false
Use-case : Set this parameter to false when your Web module contains a JAR file that is also found in the server lib directory, and you want your Web module's JAR file to be picked up first.
Default: true
Whether to use one class loader per enterprise archive (EAR) file or one class loader per Web application archive (WAR) file. Used only when ear.path or enterpriseApp.name is given.
Example: JspBatchCompiler -ear.path c:\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.
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 your WAR file relies on, for example, a JAR file that is configured in WebSphere Application Server as a shared library, then use this option to point to that JAR file. In addition, if you 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 your system-dependent path separator.
Example: JspBatchCompiler -war.path c:\myproject\examples.war -additional.classpath c:\myJars\someJar.jar;c:\myClasses
Use-case: Use this parameter to add to the class path JAR files and classes outside of your WAR file. At runtime, these same JAR files and classes have to be made available through the standard WebSphere Application Server configuration mechanisms.
Default: null
This option instructs the batch compiler to use a small class path for the Java compilation phase. The small class path greatly speeds up the compilation process. This small class path is not used by default because it includes only a subset of WebSphere Application Server JAR files. The small class path excludes many WebSphere Application Server JAR files, among which are those that contain WebSphere public APIs.
If your JSP pages do not use any WebSphere public APIs within scriptlets you can enable the small class path by using the jspCompileClasspath parameter with no value, as in Example 1 below.
If your JSP pages do use WebSphere public APIs within scriptlets, then add those additional JAR files to the jspCompileClasspath option, as in Example 2 below.
The entries are separated by spaces, and are assumed to be relative to the WebSphere Application Server installation root.
Example 1: If no public APIs are needed in JSP pages: JspBatchCompiler -enterpriseApp.name sampleApp -jspCompileClasspath
Example 2: public APIs from the admin.jar file needed in JSP pages: JspBatchCompiler -enterpriseApp.name sampleApp —jspCompileClasspath "lib/admin.jar"
Use-case: Use this parameter to speed up the Java compilation step of JSP page processing.
Default: The entire WebSphere Application Server class path is used by default.
Whether the batch compiler should generate verbose output while compiling the generated sources.
Example: JspBatchCompiler -war.path c:\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
Indicates the compiler should generate deprecation warnings while compiling the generated sources.
Example: JspBatchCompiler -war.path c:\myproject\examples.war -deprecation true
Use-case: Set this parameter to true when you want to see Java compiler deprecation messages.
Default: false
The 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.
Example: JspBatchCompiler -war.path c:\myproject\examples.war -javaEncoding Shift-JIS
Use-case: Set this parameter when the page encoding of your JSP pages is not UTF-8 compatible.
Default value: UTF-8.
Tells the batch compiler to enable assertions. If compileWithAssert is true, the batch compiler will pass the —source 1.4 option to the javac compiler. If compileWithAssert is false, no option is sent to the javac compiler. The default behavior of javac is to compile code normally even if the word assert is used as regular identifier.
Example: JspBatchCompiler -war.path c:\myproject\examples.war -compileWithAssert true
Use-case: Set this parameter to true when you want you use the assertion facility in your JSP pages and you want to be able to turn on assertions at runtime.
Default value: false
Specifies a list of strings to be passed on the Java compiler command. This is a space-separated list of the form "arg1 arg2 argn".
Example: JspBatchCompiler -war.path c:\myproject\examples.war -compilerOptions " -bootclasspath <path>"
Use-case: Use this parameter if you need Java compiler arguments other than verbose, deprecation and Assert facility support.
Default: null
Whether Jikes should be used for compiling Java sources. NOTE: Jikes is not shipped with WebSphere Application Server.
Example: JspBatchCompiler -ear.path c:\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
The file extensions to be processed by the batch compiler. This is a semicolon- or colon-separated list of the form "*.ext1;*.ext2:*.extn". Note that this parameter is not necessary for Servlet 2.4 Web applications 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.
Example: 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 article for additional information.
The level of logging that is directed to the console during batch compilation. Values are SEVERE | WARNING | INFO | CONFIG | FINE | FINER | FINEST | OFF
Example: 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
JavaServer Pages
Batch compiler ant task
Related reference
Web