Question & Answer
Question
How do I configure JSP compilation in WebSphere Application Server Community Edition?
Cause
WebSphere Application Server Community Edition uses Tomcat as the Web container. When Web applications containing JSPs are deployed on the server, WebSphere Application Server Community Edition uses Jasper to compile JSPs and stores the compiled JSPs in the following directory:
<wasce_home>/var/temp |
Answer
- Configuration at the server scope
WebSphere Application Server Community Edition can be configured to retain the compiled JSPs of all Web applications running in the server across server restarts. The procedure is as follows. - Open the following file in a text editor:
- Add the following parameters to org.apache.jasper.servlet.JspServlet:
- Create a sub-directory named worker1 in the following directory:
- JSPs from all the Web applications are compiled once into worker1 directory and persisted across server restarts.
- Configuration at the application scope
If users want to configure retaining the compiled JSPs for a single Web application, the following procedure needs to followed. - Open the web.xml file of the Web application in a text editor.
- Copy the following contents.
- Create a sub-directory named worker1 in the following directory:
- JSPs from the configured application are compiled once into worker1 directory and retained intact across server restarts.
- JSP precompilation
Before deploying Web applications on WebSphere Application Server Community Edition, users can precompile the JSPs into servlets using JASPER libraries shipped with the WebSphere Application Server Community Edition. A sample ANT script is available here. The ANT script can be configured to use JASPER libraries shipped with WebSphere Application Server Community Edition. This technique precompiles all the JSPs into servlets and generates required servlet mapping entries to be copied to the web.xml file of the Web application. The generated servlet classes can be packaged with the Web application and deployed on the server.
<wasce_home>/var/catalina/conf/web.xml |
<init-param> <param-name>scratchdir</param-name> <param-value> ../var/catalina/worker1/ </param-value> </init-param> <init-param> <param-name>keepgenerated</param-name> <param-value>false</param-value> </init-param> |
<wasce_home>/var/catalina/conf |
<servlet> <servlet-name>jsp</servlet-name> <servlet-class> org.apache.jasper.servlet.JspServlet </servlet-class> <init-param> <param-name>development</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>fork</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>scratchdir</param-name> <param-value> ../var/catalina/worker1/ </param-value> </init-param> <init-param> <param-name>keepgenerated</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>xpoweredBy</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>engineOptionsClass</param-name> <param-value> org.apache.geronimo.jasper.JspServletOptions </param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jspx</url-pattern> </servlet-mapping> |
<wasce_home>/var/catalina/conf |
[{"Product":{"code":"SS6JMN","label":"WebSphere Application Server Community Edition"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Tomcat","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"2.1.1.2;2.1.1.1;2.1.0.1;2.1;2.0.0.3;2.0.0.2;2.0.0.1;2.0","Edition":"Entry;Enhanced;Elite","Line of Business":{"code":"LOB45","label":"Automation"}}]
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21303765