You can configure a JavaServer Pages (JSP) class to be loaded by either the JSP engine’s class loader or by the Web module’s class loader.
By default, a JSP class is loaded by a unique instance of the JSP engine’s class loader. The JSP engine’s class loader enables reloading at runtime of a JSP class when the JSP source or one of its dependents is modified. This allows you to reload a single JSP class when necessary, without affecting any other loaded JSP classes.
You can configure a JSP file as a servlet in the web.xml file. There are two ways to do this. They are described in the table below.
Scenario | Example | compatible with runtime reloading | multiple class loaders used? | useFullPackageNames |
<jsp-file> | <servlet> <servlet-name>jspOne</servlet-name> <jsp-file>jspOne.jsp</jsp-file> </servlet> |
Yes | Yes | Can be true or false |
<servlet-class> | <servlet> <servlet-name>jspTwo</servlet-name> <servlet-class>_ibmjsp.jspTwo</servlet-class> </servlet> |
No | No | Must be true |
The JSP batch compiler tool helps you configure JavaServer Pages files as servlets. When useFullPackageNames is true, the JSP batch compiler generates <servlet> and <servlet-mapping> elements for each JSP file that it successfully translates and compiles. The elements are written to a web.xml fragment file named generated_web.xml which is located in the binaries WEB-INF directory of a Web module processed by the JSP file batch compiler (this directory is located within the deployed application’s ear file). You can copy and paste all or some of these elements into the web.xml file to configure JavaServer Pages files as servlets.
If the JSP batch compiler is executed on a pre-deployed application then the web.xml file is in the Web module’s WEB-INF directory.