JSPs (JSP) runtime reloading settings
JSPs files can be translated and compiled at run time when the JSP file or its dependencies are modified. This is known as JSP reloading.
Best practice: Use an assembly tool, such as Rational Application Developer, to modify IBM extension and binding files. We can convert extension and binding files within modules from XMI to XML using the IBM Bindings and Extensions Conversion Tool for Multi-Platforms.bprac
JSP reloading is enabled through the reloadEnabled JSP engine parameter in the WEB-INF/ibm-web-ext.xmi or WEB-INF/ibm-web-ext.xml file.
ibm-web-ext.xmi example:
<jspAttributes xmi:id="JSPAttribute_1" name="reloadEnabled" value="true"/>
ibm-web-ext.xml example:
<?xml version="1.0" encoding="UTF-8"?> <web-ext xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0"> <jsp-attribute name="trackDependencies" value="true" /> <jsp-attribute name="disableJspRuntimeCompilation" value="true" /> <jsp-attribute name="reloadEnabled" value="true"/> <reload-interval value="5"/> <auto-encode-requests value="false"/> <auto-encode-responses value="false"/> <enable-directory-browsing value="false"/> <enable-file-serving value="false"/> <pre-compile-jsps value="false"/> <enable-reloading value="true"/> <enable-serving-servlets-by-class-name value="false" /> </web-ext>Supported configurations: For IBM extension and binding files, the .xmi or .xml file name extension is different depending on whether you are using a pre-Java EE 5 application or module or a Java EE 5 or later application or module. An IBM extension or binding file is named ibm-*-ext.xmi or ibm-*-bnd.xmi where * is the type of extension or binding file such as app, application, ejb-jar, or web. The following conditions apply:
- For an application or module that uses a Java EE version prior to version 5, the file extension must be .xmi.
- For an application or module that uses Java EE 5 or later, the file extension must be .xml. If .xmi files are included with the application or module, the product ignores the .xmi files.
However, a Java EE 5 or later module can exist within an application that includes pre-Java EE 5 files and uses the .xmi file name extension.
The ibm-webservices-ext.xmi, ibm-webservices-bnd.xmi, ibm-webservicesclient-bnd.xmi, ibm-webservicesclient-ext.xmi, and ibm-portlet-ext.xmi files continue to use the .xmi file extensions. sptcfg
The following table contains suggested reload settings for production and development environments.
Configuration Attribute Production Environment setting Development Environment setting reloadEnabled false true reloadInterval n/a (ignored if reloadEnabled is false) approximately 5 seconds trackDependencies n/a (ignored if reloadEnabled is false) true Alternatively, set this to false to improve response time if dependencies are not changing disableJspRuntimeCompilation true - Alternatively, set this to false if JSP files are not pre-compiled and therefore need to be compiled on the first request. false The default for the reloadEnabled parameter is true. If the reloadEnabled parameter is set to true, a JSP file is reloaded at run time if the JSP file and its class file do not have the same timestamp. In addition, if trackDependencies is set to true then the JSP file is reloaded if the timestamp of any of its dependencies has changed since the JSP class file was last generated. If the reloadEnabled parameter is set to false, a JSP file is still compiled if necessary on the first request to it unless the parameter disableJspRuntimeCompilation is true. For example, when disableJspRuntimeCompilation is false and reloadEnabled is false, a JSP file is compiled on the first request if the class file is outdated. It would not compile on subsequent requests, even if the JSP source file is modified or the class file is deleted,, unless reloadEnabled is true.
Reload interval
The reload interval is set through the reloadInterval JSP engine parameter.
ibm-web-ext.xmi example:
<jspAttributes xmi:id=JSPAttribute_1 name=reloadInterval value=5/>
ibm-web-ext.xml example:
<?xml version="1.0" encoding="UTF-8"?> <web-ext xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0"> <jsp-attribute name="trackDependencies" value="true" /> <jsp-attribute name="disableJspRuntimeCompilation" value="true" /> <jsp-attribute name="reloadInterval" value="5"/> <reload-interval value="5"/> <auto-encode-requests value="false"/> <auto-encode-responses value="false"/> <enable-directory-browsing value="false"/> <enable-file-serving value="false"/> <pre-compile-jsps value="false"/> <enable-reloading value="true"/> <enable-serving-servlets-by-class-name value="false" /> </web-ext>If reloading is enabled, the reloadInterval parameter value determines the delay between checks to see if a JSP file is outdated. For example, if reloadInterval is 5, the JSP engine checks to see if a JSP file is outdated only when the last such check was done more than five seconds prior to the current request for the JSP file. Once the reloadInterval is exceeded, reload checking is performed and the reload interval timer is reset to 0 for that JSP file. The larger the reloadInterval, the less frequently the JSP engine checks for the need to reload a JSP file.
Dependency tracking
Dependency tracking is set through the trackDependencies JSP engine parameter.
ibm-web-ext.xmi example:
<jspAttributes xmi:id="JSPAttribute_1" name="trackDependencies" value="true"/>
ibm-web-ext.xmi example:
<?xml version="1.0" encoding="UTF-8"?> <web-ext xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version="1.0"> <jsp-attribute name="trackDependencies" value="true" /> <jsp-attribute name="disableJspRuntimeCompilation" value="true" /> <jsp-attribute name="reloadInterval" value="5"/> <reload-interval value="5"/> <auto-encode-requests value="false"/> <auto-encode-responses value="false"/> <enable-directory-browsing value="false"/> <enable-file-serving value="false"/> <pre-compile-jsps value="false"/> <enable-reloading value="true"/> <enable-serving-servlets-by-class-name value="false" /> </web-ext>If reloading is enabled, the trackDependencies parameter value determines whether the JSP engine tracks modifications to the requested JSP file dependencies as well as to the JSP file itself. The three types of dependencies tracked by the JSP engine are:
- files statically included in the JSP file
- tag files referenced in the JSP file (excluding tag files that are in JAR files)
- TLDs referenced in the JSP file (excluding TLDs that are in JAR files)
Dependency tracking information is always included in the generated class file even if trackDependencies is false. The information is not used by the JSP engine or batch compiler unless the trackDependencies parameter is true. This means that we can enable dependency tracking without having to recompile JSP files.
For example, the toplevel.jsp file statically includes the footer.jspf file. When the toplevel.jsp file is compiled, the path to the footer.jspf file and its timestamp are stored in the toplevel.jsp's class file. As a result, the footer.jspf file is modified and the toplevel.jsp file is requested. Now that the reload interval for the toplevel.jsp file has been exceeded, the JSP engine compares the timestamp stored in the class file with the footer.jspf file timestamp on disk. Because the timestamps are different, the toplevel.jsp file is compiled, picking up the modification to the footer.jspf file. In order for dependency tracking to work, the trackDependencies value must be set to true at the time a JSP file is requested at run time or is processed by the batch compiler.
Disable compilation
Disablement of run time compilation of JSPs is set via the disableJspRuntimeCompilation JSP engine parameter.
ibm-web-ext.xmi example:
<jspAttributes xmi:id="JSPAttribute_1" name="disableJspRuntimeCompilation" value="true"/>
ibm-web-ext.xml example:
<?xml version="1.0" encoding="UTF-8"?> <web-ext xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd" version=1.0> <jsp-attribute name="trackDependencies" value="true" /> <jsp-attribute name="disableJspRuntimeCompilation" value="true" /> <jsp-attribute name="reloadInterval" value="5"/> <reload-interval value="5"/> <auto-encode-requests value="false"/> <auto-encode-responses value="false"/> <enable-directory-browsing value="false"/> <enable-file-serving value="false"/> <pre-compile-jsps value="false"/> <enable-reloading value="true"/> <enable-serving-servlets-by-class-name value="false" /> </web-ext>If the disableJspRuntimeCompilation parameter is set to true, the JSP engine at run time does not translate and compile JSP files; the JSP engine loads only precompiled class files. JSP source files do not need to be present in order for the class files to be loaded. With this option set to true, an application can be installed without JSP source, but must have precompiled class files. There is a web container custom property of the same name that can be used to determine the behavior of all web modules installed in a server. If both the web container custom property and the JSP engine option are set, the JSP engine option takes precedence. Setting the disableJspRuntimeCompilation parameter to true automatically sets reloadEnabled to false.
Reload processing sequence
The processing sequence pertaining to JSP file reloading when trackDependencies is false is shown in Figure 1.
Figure 1. Reload processing sequence when trackDependencies is false.
When trackDependencies is true, the JSP engine does additional file system processing to determine if any of a JSP file's dependencies have changed since the JSP file was last translated and compiled. Figure 2 shows the additional processes that are performed on the 'No' path of flow chart labeled "is JSP class file outdated?". We can see that the path taken when disableJspRuntimeCompilation is true is the most efficient path.
Figure 2. Additional reload processing performed when trackDependencies is true.
Related tasks
Configure JSP engine parameters
JSP engine configuration parameters Custom property settings Web container custom properties
Related information:
IBM Bindings and Extensions Conversion Tool for Multi-Platforms.