 | Level: Intermediate Scott Johnson (scottjoh@us.ibm.com)IBM WebSphere Application Server Development
19 Jan 2004 This article, the first in a three-part series, describes the internal operations of the batch compiler and explores the batch compiler configuration parameters that are available in WebSphere Application Server Technology for Developers V6.0. Also focused on WebSphere Application Server V6.0 TD, Part 2 will cover performance tuning the JSP Engine, and Part 3 will examine the architecture of the JavaServer Pages Engine.
Introduction
JavaServer Pages (JSPs) can be compiled during Web application development, before an application is deployed. Batch compilation of JSPs in a predeployed application simplifies the deployment process and improves the run time performance of JSPs by eliminating first-request compilations. The batch compiler also operates on enterprise applications that have been deployed into IBM WebSphere Application Server.
This article will describe the internal operations of the batch compiler, and will explore all of the batch compiler configuration parameters that are available in WebSphere Application Server Version 6.0 TD. Parts 2 and 3 of this series will cover performance tuning the JSP Engine and examining the architecture of the JavaServer Pages Engine, respectively, in WebSphere Application Server Technology for Developers V6.0 TD.
Batch compiler operation
The batch compiler validates the syntax of JSPs, translates the JSPs into Java source files, and compiles the Java source files into Java Servlet classfiles. Similarly, it validates Tag files and generates their Java implementation classes.
The batch compiler has many configuration parameters that enable the application developer, or deployer, to control its behavior (see Batch Compiler Configuration Parameters). Even though it can be configured in many ways, there is only one required configuration parameter: the batch compiler target. The default values for the configuration parameters will be satisfactory in most cases, which makes the tool easy to use
Supported JSP and servlet specifications
The batch compiler will operate on Web modules supporting the Servlet 2.4 specification, or previous specifications back to Servlet 2.2. It will operate on JSPs written to the JSP 2.0 specification, or previous specifications back to JSP 1.0. It will recognize a Servlet 2.4 (JSP 2.0) deployment descriptor (web.xml) and use any jsp-config elements it may contain. In a Servlet 2.3 (JSP 1.2) or Servlet 2.2 (JSP 1.1) deployment descriptor, the batch compiler will recognize and use any taglib elements that the descriptor may contain.
The batch compiler target
The batch compiler can be executed against compressed or expanded Enterprise Application Archives (EARs) and Web Application Archives (WARs), 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 in order for the batch compiler to be executed. If the batch compiler is executed while the target sever is running, the server will not be aware of an updated class file and will not load that class file unless the enterprise application is restarted. When the target is a compressed EAR or WAR, the batch compiler must expand it before executing. Table 3 describes the batch compiler's expansion of EARs and WARs.
Processing of Web modules
The batch compiler operates on one Web module at a time. If the target is either an EAR or an installed enterprise application that contains more than one Web module, the batch compiler operates on each Web module individually. This occurs because JSPs are configured on a Web module basis, via the Web module's web.xml deployment descriptor.
Within a Web module, the batch compiler processes one directory at a time. It validates and translates each JSP individually, and then invokes the Java compiler for the entire group of generated Java source files in that directory. If one JSP fails during the Java compilation phase, the Java compiler may not create classfiles for most or all of the JSPs 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
- The url-pattern property of the jsp-property-group elements in the deployment descriptor 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 will also process 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 will also be processed and will override the JSP Engine configuration parameter jsp.file.extensions.
It is a good idea to give JSP "fragments" an extension that will not be processed by the batch compiler. Statically-included fragments that will not stand alone will generate translation or compilation errors if processed. The JSP 2.0 specification suggests the extension .jspf for such files.
JSP Engine configuration parameters
The batch compiler has nine configuration parameters that have equivalents in the WebSphere Application Server JSP Engine. The JSP Engine parameters, if present, act as defaults when the equivalent batch compiler parameter is not given. (See Three groups of configuration parameters and their precedence) These parameters are:
Table 1. Batch compiler parameters and equivalent JSP Engine parameters
Batch Compiler Configuration Parameter | JSP Engine Configuration Parameter | -keepgenerated | keepgenerated | -verbose | verbose | -deprecation | deprecation | -compileWithAssert | compileWithAssert | -trackDependencies | trackDependencies | -usePageTagPool | usePageTagPool | -useThreadTagPool | useThreadTagPool | -useJikes | useJikes | -jsp.file.extensions | jsp.file.extensions |
The batch compiler does not create, or set the values of, equivalent JSP Engine parameters. This means that if a JSP 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. If precompiled JSPs are never modified in a deployed Web module then this is not an issue. If they are modified in a deployed Web module, then the engine's parameters should be set to the same values used in batch compilation.
Determining when a JSP needs to be compiled
A JSP's classfile is considered to be outdated when its timestamp is different from -- is either newer or older than -- the timestamp of the JSP. The batch compiler will translate and compile a JSP when the classfile is outdated, or when the classfile does not exist. (There are JSP Engine configuration parameters that can be used to disable run time compilation of JSPs even when their class files are outdated. See JSP engine performance considerations .)
A JSP may have dependencies (see trackDependencies). A JSP classfile will be regenerated if the trackDependencies configuration parameter is set to true and if the timestamp of any one of the JSP's dependencies has changed since the JSP was last translated and compiled. The names and timestamps of a JSP's dependencies are stored within the classfile, which enables the batch compiler (and the JSP Engine at run time) to determine if a dependency has changed.
Batch compiler compilation of JSPs may be forced -- regardless of whether or not the classfiles are outdated or dependencies have changed -- by using the parameter forceCompilation (see Optional configuration parameters).
Determining where classfiles are generated
The WebSphere Application Server JSP Engine at run time will load JSP classfiles from either the WebSphere Application Server temp directory or a Web module's WEB-INF/classes directory. The WebSphere Application Server temp directory is typically {WAS_ROOT}/temp . The Engine searches for a classfile in the temp directory first, and second in the Web module's WEB-INF/classes directory. Figure 1 shows the processing logic of the JSP Engine at run time.
The batch compiler supports the generation of classfiles in both the WebSphere Application Server temp directory and a Web module's WEB-INF/classes directory, depending on the type of batch compiler target. In addition, the batch compiler enables generation of classfiles into any directory on the file system, outside the target application. See Table 4 for details.
Generating classfiles into a Web module's WEB-INF/classes directory enables the Web module to be deployed as a self-contained WAR, or a WAR inside of an EAR.
Figure 1. Where the JSP Engine looks for JSP classfiles
Batch compiler classpath
The batch compiler builds its classpath as shown in Table 2. When the batch compiler target is a WAR (war.path is supplied) the configuration parameter additional.classpath can be used to give extra classpath information.
Table 2. Batch Compiler Classpath
| Location Added to Classpath | Batch Compiler Target | | enterpriseapp.name | ear.path | war.path | | WebSphere Application Server JARs and classes | yes | yes | yes | | JARs listed in manifest class-path for a Web module | yes | yes | yes, when the target WAR is inside an EAR and -extractToDir is not used; otherwise, no | | Shared Libraries | yes | no | no | | Web module JAR and classes | yes | yes | yes | | additional.classpath parameter to batch compiler | no | no | yes |
Logging
The batch compiler logs its operations, both to the console and to a log file {WAS_ROOT}/logs/jspBatchCompilerTrace.log . The default logging level, CONFIG, will log processing information and any exceptions or JSP translation or compiler errors encountered. If a finer level of logging is needed for debugging, the log.level parameter can be used (see log.level).
JSP Engine performance considerations
The JSP Engine offers a configuration parameter -- disableJspRuntimeCompilation -- that disables the run time compilation of JSPs. This is the most efficient mode for the engine, because it will never check to see if a class file is outdated, avoiding all file system checks. This setting requires that a JSP's classfile be present, even on the first request. In order to make use of this parameter, all JSP classfiles must exist when the application is deployed. The batch compiler parameter forceCompilation can be used in the final stages of application assembly to ensure that all JSP class files exist before deployment.
The JSP Engine parameters reloadEnabled and reloadInterval can be used when JSPs are modified at run time and need to be reloaded to pick up modifications. The reloadEnabled parameter determines whether or not a JSP file will be retranslated and recompiled at run time if the JSP file or its dependencies (see trackDependencies ) are modified. Note that if reloadEnabled is false (the default) a JSP is still compiled if necessary on the first request to it unless the attribute disableJspRuntimeCompilation is true. If reloading is enabled, reloadInterval determines how many seconds between requests for a JSP the engine will wait before checking to see if reloading of the JSP is necessary.
The JSP Engine also offers a development-mode parameter, trackDependencies. If your server is being used during development it is useful to have a JSP recompiled when its dependencies change. This is the most inefficient mode for the engine as it requires file system checks on every request to a JSP. If you wish to use this engine parameter, be sure to use the equivalent batch compiler parameter before deploying the application into WebSphere Application Server -- the batch compiler will generate all the necessary dependency tracking information which will then be used by the engine at run time. The engine will not automatically create this information, when its trackDependencies parameter is set to true, unless a JSP is recompiled because it has changed or its class file has been deleted.
The JSP Engine parameters useThreadTagPool and usePageTagPool can improve performance of JSPs that make heavy use of custom tags. Be sure to batch compile with the desired batch compiler equivalent parameter set to true, so that the JSP Engine will be able to make use of the pooling at run time.
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 can be found in {WAS_ROOT}/bin. An Ant task (see Batch Compiler Ant Task) is also available for executing the batch compiler using Ant.
The batch compiler command looks like this:
JspBatchCompiler
-ear.path <path> | -war.path <path> | -enterpriseapp.name <name>
[-response.file <filename>]
[-webmodule.name <name>]
[-filename <jsp name | directory name>]
[-config.root <path>]
[-cell.name <name>]
[-node.name <name>]
[-server.name <name>]
[-extractToDir <path>]
[-compileToDir <path>]
[-compileToWebInf <true|false>]
[-forceCompilation <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>]
[-verbose <true|false>]
[-deprecation <true|false>]
[-compileWithAssert <true|false>]
[-useJikes <true|false>]
[-jsp.file.extensions <file extensions to process>]
[-log.level <SEVERE | WARNING | INFO | CONFIG | FINE | FINER | FINEST | OFF>]
|
A sample batch compiler command entered from the Windows command prompt:
C:\WAS\AppServer\bin>jspbatchcompiler -enterpriseapp.name sampleApp -forcecompilation true -verbose true
Batch compiler configuration parameters
- The batch compiler configuration parameters are not case sensitive. For example:
-usePageTagPool is the same as -usepagetagpool.
- Each parameter must be followed by its value, and the parameter and its value must be separated by one or more spaces. For example:
-enterpriseapp.name myWebApplication.
- The parameters can appear in any order on the command line and in a response file. The response.file parameter is described below under Optional Configuration Parameters.
Three groups of configuration parameters and their precedence
The batch compiler is aware of three groups of configuration parameters:
- JSP Engine configuration parameters for a Web module.
These are the parameters that have been set for a particular Web module's JSP support, usually within a deployed application. For example, the keepgenerated parameter has been available for many releases of WebSphere Application Server to control the saving or deleting of the Java source that is generated by the JSP Engine.
- JSP Engine configuration parameters are stored in a Web module's configuration directory, in the file
WEB-INF/ibm-web-ext.xmi. An example of a configuration directory is:
{WAS_ROOT}/config/cells/cellname/applications/enterpriseappname/deployments/deployedname/webmodulename
- If an application was deployed into WebSphere Application Server with the flag "Use Binary Configuration" set to true, then the
WEB-INF/ibm-web-ext.xmi file is looked for in a Web module's binaries directory, not in the configuration directory. An example of a binaries directory is:
{WAS_ROOT}/installedApps/nodename/EnterpriseAppName/WebModuleName/
- The entry in
ibm-web-ext.xmi for a JSP Engine configuration parameter looks like the following example:
<jspAttributes xmi:id="JSPAttribute_6" name="keepgenerated" value="true"/>
- Response file configuration parameters.
These are the parameters that are found in a batch compiler response file.
- Batch compiler command line configuration parameters.
These are the parameters entered on the command line when running the batch compiler.
The batch compiler looks at all three groups of configuration parameters in order to determine which value for a parameter should be used when compiling JSPs. When resolving the value for a given parameter, the precedence is:
- If the parameter is found on the command line, its value is used. If the parameter is not found on the command line, the batch compiler looks for
- the parameter in a response file named on the command line. If no response file is named, or if the parameter is not found therein, the batch compiler looks for the parameter in
- the Web module's JSP Engine configuration parameters. (See JSP Engine configuration parameters.)
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, in the Required configuration parameters and Optional configuration parameters sections.
Required configuration parameters: the batch compiler target
One and only one of ear.path, war.path and enterpriseapp.name is required. These parameters do not have to be given on the command line; they may appear in a response file instead.
ear.path
| Specifies the full path to a single compressed or expanded enterprise application archive (EAR). | | Example: | JspBatchCompiler -ear.path c:\myproject\sampleApp.ear | | Use case: | Use this parameter to batch compile an EAR that is under development or that is ready to be deployed into WebSphere Application Server. Note that an enterprise application that has been deployed can also be pointed to by this parameter, by giving the full path to the root of the installed enterprise application. However, if the enterprise application has been configured to use shared libraries, they will not be picked up when pointed to by ear.path. In that case, use enterpriseapp.name. | | Default value: | None. |
war.path
| Specifies the full path to a single compressed or expanded Web application archive (WAR). | | Example: | JspBatchCompiler -war.path c:\myproject\examples.war | | Use case: | Use this parameter to batch compile a WAR that is under development or that is ready to be deployed into WebSphere Application Server. A Web module within a deployed enterprise application can also be pointed to by this parameter, by giving the full path to the root of the installed Web module. As with ear.path, if the enterprise application has been configured to use shared libraries, they will not be picked up when pointed to by war.path. In that case, use enterpriseapp.name, or use the additional.classpath parameter to add the needed classes and JARs to the batch compiler classpath. | | Default value: | None. |
enterpriseapp.name
| Specifies the name of a single enterprise application that has been deployed into WebSphere Application Server. The server does not need to be running when this parameter is used. This parameter depends on correct settings for the config.root, cell.name, node.name and server.name parameters. If the default values for these are not correct for your environment, override them on the command line or in a response file. | | Examples: | JspBatchCompiler -enterpriseapp.name sampleApp
JspBatchCompiler -enterpriseapp.name App -webmodule.name my.war -filename /aDir/main.jsp | | Use case: | Use this parameter to batch compile an enterprise application that has been deployed into WebSphere Application Server. Use the webmodule.name parameter to compile a specific Web module within the application. Use the filename parameter along with the webmodule.name parameter to compile a specific JSP file or directory within that Web module. | | Default value: | None. |
Optional configuration parameters
response.file
Specifies the path to a file that contains configuration parameters to be 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 order to avoid circular dependencies. A 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 | | Use case: | Using a response file allows convenient configuration of multiple batch compiler targets. | | Default value: | None. |
webmodule.name
Specifies the name of a single Web module to batch compile. This parameter is used only when ear.path or enterpriseapp.name is given, and the Web module must be found within the named EAR or enterprise application. webmodule.name is ignored if war.path is given. | | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -webmodule.name myWebModule.war | | Use case: | This parameter is useful when JSPs in a specific Web module within a deployed enterprise application need to be regenerated -- because all shared library and manifest class-path dependencies will be picked up. | | Default value: | all Web modules in an EAR or enterprise application will be compiled if this parameter is not given. |
filename
| Specifies the name of a single JSP file that you want to compile. 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 compiled. The name is relative to the context root of the Web module. | | Example: | if you want to compile myTest.jsp, and it is found in /subdir/myJSPs, you would enter
-filename /subdir/myJSPs/myTest.jsp.
If you want to compile all JSPs in /subdir/myJSPs and its child directories, you would enter
-filename subdir/myJSPs.
| | Use case: | Usually, this parameter is given when you are compiling a specific Web module in which the named JSP file or directory exists. If you name an enterprise application or EAR but do not supply the webmodule.name parameter, the batch compiler will look for the filename in every Web module, and if the filename is not found in every one of the Web modules, then the batch compiler will return a fail value. | | Default value: | all JSPs in the Web module will be compiled. Entering -filename / is equivalent to the default. |
config.root
| Specifies the location of the WebSphere configuration directory. This argument is used only when enterpriseapp.name is given. | | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -config.root c:\WAS\AppSever\altConfigDir | | Use case: | Use this parameter to override the default if necessary. | | Default value: | typically {WAS_ROOT}/config. The default is obtained from the file setupCmdLine.[bat/sh] in {WAS_ROOT}/bin. |
cell.name
| Specifies the name of the cell in which this application is installed. This argument is used only when enterpriseapp.name is given. | | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -cell.name someCellName | | Use case: | Use this parameter to override the default if necessary. | | Default value: | The default is obtained from the file setupCmdLine.[bat/sh] in {WAS_ROOT}/bin. The symbolic name of this variable is WAS_CELL. |
node.name
| Specifies the name of the node in which this application is installed. This argument is used only when enterpriseapp.name is given. | | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -node.name someNodeName | | Use case: | Use this parameter to override the default if necessary. | | Default value: | The default is obtained from the file setupCmdLine.[bat/sh] in {WAS_ROOT}/bin. The symbolic name of this variable is WAS_NODE. |
server.name
| Specifies the name of the server in which this application is installed. This argument is used only when enterpriseapp.name is given. | | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -server.name someServerName | | Use case: | Use this parameter to override the default if necessary. | | Default value: | server1. |
extractToDir
| Specifies the directory into which predeployed EARs and WARs (indicated by the ear.path and war.path parameters) 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 Table 3. | | Example: | JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -extractToDir c:\myTempDir | | Use case: | A compressed archive must be extracted before it is batch compiled. An expanded archive can be extracted to a new directory as well. In both cases, extraction leaves the original archive untouched, which may be useful while development is underway. | | Default value: | See Table 3. |
Table 3. The extractToDir parameter
| 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 will remove it completely before extracting the archive.
If the batch compiler exits with no errors, it will compress the archive in place in the extractToDir, even if the original EAR or WAR was expanded.
If errors are encountered during compilation, the EAR or WAR is left in the expanded state even if the original EAR or WAR was compressed.
| | extractToDir not supplied | The batch compiler operates on the EAR or WAR in place (does not extract it to another directory) and the archive remains expanded after the batch compiler finishes. | The batch compiler will extract 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.
|
compileToDir
| Specifies the directory into which JSPs will be translated into Java sourcefiles and compiled into classfiles. This directory can be anywhere on the file system, but the batch compiler's default behavior is usually adequate. The batch compiler's behavior when compiling classfiles is described in Table 4. | | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -compileToDir c:\myTargetDir | | Use case: | This parameter enables you to generate the Java and class files into a directory totally outside 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 value: | See Table 4. |
compileToWebInf
Indicates that the target directory for the compiled JSP classfiles 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.
Note that the batch compiler's default behavior is to compile the Web module's WEB-INF/classes directory. The batch compiler's behavior when compiling classfiles is described in Table 4.
| | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -compileToWebInf false | | Use case: | Set this parameter to false when enterpriseApp.name is supplied and you want the classfiles 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 value: | true; see Table 4. |
Table 4. The batch compiler's behavior when compiling classfiles
| ear.path or war.path supplied | enterpriseApp.name supplied | | compileToDir not supplied;
compileToWebInf not supplied, or is true
| The classfiles are compiled into the Web module's WEB-INF/classes directory | The classfiles are compiled into the Web module's WEB-INF/classes directory. | | compileToDir not supplied;
compileToWebInf is false
| The classfiles are compiled into the Web module's WEB-INF/classes directory. | The classfiles are compiled into the WebSphere temp directory (usually {WAS_ROOT}/temp). | | compileToDir is supplied;
compileToWebInf not supplied, or is either true or false
| The classfiles are compiled into the directory indicated by compileToDir. | The classfiles are compiled into the directory indicated by compileToDir. |
forceCompilation
| Forces the batch compiler to recompile all JSP resources regardless or whether or not the JSP 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 value: | false. |
trackDependencies
Instructs the batch compiler to recompile a JSP if any of its dependencies have changed, even if the JSP itself has not changed. Note that tracking dependencies incur a significant run time performance penalty because the JSP Engine will check the file system on every request to a JSP to see if any of its dependencies have changed. The dependencies tracked by WebSphere Application Server are:
- files statically included in the JSP.
- tag files used by the JSP.
- TLD files used by the JSP (excluding TLDs that are in JARs).
| | Example: | JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -trackDependencies true | | Use case: | Useful in a development environment. | | Default value: | false. |
createDebugClassfiles
| Instructs the batch compiler to generate classfiles 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 JSPs in your IDE. | | Default value: | false. |
keepgenerated
| Instructs the batch compiler to retain the Java source files created during the translation phase of processing. They are located in the same directory as the generated classfiles. | | 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 value: | false |
keepGeneratedclassfiles
| Instructs the batch compiler to retain the classfiles created during the compilation of the Java source files. | | Example: | JspBatchCompiler -ear.path c:\myproject\sampleApp.ear -keepGeneratedclassfiles false
-extractToDir c:\myTempDir -keepgenerated false -keepGeneratedclassfiles false
| | Use case: | Set this parameter to false if you only want to see if there are any translation or compilation errors in your JSPs, and if you do not care about the generated class files. If paired with keepgenerated false, this parameter will result in all generated files being removed before the batch compiler completes. | | Default value: | true. |
usePageTagPool
| Enables or disables the reuse of custom tag handlers on an individual JavaServer 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 value: | false |
useThreadTagPool
| 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 value: | false |
classloader.parentFirst
| Search order for loading classes. Default is to search parent classloader prior to application classloader. Used only 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 that is also found in the server lib directory, and you want your Web module's JAR to be picked up first. | | Default value: | true |
classloader.singleWarClassloader
| Specifies whether to use one classloader per EAR or one classloader per WAR. 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 JARs and classes in another Web module in the same enterprise application. | | Default value: | false: one classloader is created per WAR with no visibility of classes in other Web modules. |
additional.classpath
Specifies additional classpath entries to be used when parsing and compiling JSP pages. Used only when war.path is given. When war.path is the target, WebSphere Shared Libraries are not picked up by the batchcompiler. Therefore, if your WAR relies on, for example, a JAR that is configured in WebSphere Application Server as a Shared Library then use this option to point to that JAR. In addition, if you give war.path and also use the -extractToDir parameter, then any JARs that are in the WAR's manifest class-path will not be added to the classpath (since the WAR has now been extracted by itself outside the EAR in which it resides). Use -additional.classpath in this case to point to the necessary jars.
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 classpath JARs and classes outside your WAR. At run time, these same JARs and classes will have to be made available via standard WebSphere Application Server configuration mechanisms. | | Default value: | empty |
verbose
| Specifies whether to output messages about what the compiler is doing when the JSP is compiled | | Example: | JspBatchCompiler war.path c:\myproject\examples.war -verbose true | | Use case: | Set this parameter to true when you want to see Java compiler classloading and other messages. | | Default value: | false |
deprecation
| Specifies whether deprecation warnings should be emitted when the JSP is compiled. | | 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 value: | false |
compileWithAssert
| 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 JSPs and you want to be able to turn on assertions at run time. | | Default value: | false |
useJikes
| Specify 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 |
jsp.file.extensions
Specify 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 webapps 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 JSPs. | | Example: | JspBatchCompiler -enterpriseApp.name sampleApp -jsp.file.extensions *jspz;*.jspt | | Use case: | Use this parameter to add additional extensions to be processed by the batch compiler. | | Default value: | empty. See JSP File Extensions |
log.level
| Specify the level of logging that will be 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 will generate the most output; useful for debugging. | | Default value: | CONFIG |
Batch compiler ant task
The ant task JspC exposes all the batch compiler configuration options. It executes the batch compiler under the covers. It is backward compatible with the WebSphere Application Server 5.x version of the JspC ant task. Table 5 lists all the ant task attributes and their batch compiler equivalents. An example build.xml is shown in Listing 1. The Javadoc for JspC is available in the download file.
Table 5. JspC Ant Task Attributes and their Batch Compiler Equivalents
| JspC Attribute | Equivalent Batch Compiler Parameter | earPath | -ear.path | warpath | -war.path | src
Same as warPath, for backward compatibility
| -war.path | enterpriseAppName | -enterpriseapp.name | responseFile | -response.file | webmoduleName | -webmodule.name | fileName | -filename | configRoot | -config.root | cellName | -cell.name | nodeName | -node.name | serverName | -server.name | extractToDir | -extractToDir | compileToDir | -compileToDir | toDir
same as compileToDir, for backward compatibility
| -compileToDir | compileToWebInf | -compileToWebInf | forceCompilation | -forceCompilation | trackDependencies | -trackDependencies | createDebugClassfiles | -createDebugClassfiles | keepgenerated | -keepgenerated | keepGeneratedclassfiles | -keepGeneratedclassfiles | usePageTagPool | -usePageTagPool | useThreadTagPool | -useThreadTagPool | classloaderParentFirst | -classloader.parentFirst | classloaderSingleWarClassloader | -classloader.singleWarClassloader | additionalClasspath | -additional.classpath | classpath
same as additionalClasspath, for backward compatibility
| -additional.classpath | verbose | -verbose | deprecation | -deprecation | compileWithAssert | -compileWithAssert | useJikes | -useJikes | jspFileExtensions | -jsp.file.extensions | logLevel | -log.level | wasHome | none | classpathref | none |
Listing 1. Example build.xml Using the JspC Task
<project name="jsp" default="jspc_test" basedir=".">
<taskdef name="wsjspc" classname="com.ibm.websphere.ant.tasks.JspC"/>
<target name="jspc_test" description="example usage of JspC task">
<wsjspc wasHome="C:\WAS\AppSer"
earpath="C:\WAS\AppSer\installedApps\sdjt30\myApp.ear"
webmodulename="examples.war"
forcecompilation="true"
verbose="false"
deprecation="false"
loglevel="CONFIG"
/>
</target>
</project>
|
Conclusion
The WebSphere Application Server batch compiler is a highly configurable tool that enables compilation of JSPs in compressed and expanded EARs and WARs, as well as in enterprise applications that have been deployed into WebSphere Application Server. It can help simplify application deployment by enabling the precompilation of JSPs directly into a Web module. It is aware of all JSP Engine run time configuration attributes, enabling the generation of JSP class files that can be used in the run time engine without recompilation. During application development, it is a convenient tool for verifying that all JSP files and their included files are valid, and that all classes and JARs they depend on are visible.
Acknowledgements
The author wishes to thank Todd Kaplinger and Richard Backhouse for their contributions to this article.
Download | Name | Size | Download method |
|---|
| JSPBatchcompilerWAS6TD.zip | 7 KB | FTP | HTTP |
Resources
About the author  | |  | Scott Johnson is the Team Lead for the WebSphere Application Server JSP Engine. He joined IBM at the Research Triangle Park Lab in 2000, after 17 years as a programmer and project lead. |
Rate this page
|  |