How to prevent JSP recompilation in WebLogic Server

My previous post explains how to precompile JSPs with the WebLogic wlappc Ant task. This is a follow-up explaining how to prevent WebLogic Server to recompile the JSPs completely.

Add the following snippet to the weblogic.xml of your WAR.

<jsp-descriptor>
    <page-check-seconds>-1</page-check-seconds>
    <precompile>false</precompile>
</jsp-descriptor>

Add the following snippet to the web.xml of your WAR.

<servlet>
    <servlet-name>JSPClassServlet</servlet-name>
    <servlet-class>weblogic.servlet.JSPClassServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>JSPClassServlet</servlet-name>
    <url-pattern>*.jsp</url-pattern>
</servlet-mapping>

Changes to the weblogic.xml of your WAR

WebLogic Server will never check to see if JSP files have changed and need recompiling when you set page-check-seconds=-1 in the <jsp-descriptor> element.

You must make sure WebLogic Server does not precompile all modified JSPs when the Web application is (re-)deployed or when starting the server by setting precompile=false (also in the <jsp-descriptor> element).

Example:

<jsp-descriptor>
    <page-check-seconds>-1</page-check-seconds>
    <precompile>false</precompile>
</jsp-descriptor>

More information about WebLogic’s <jsp-descriptor> element can be found here.

Changes to the web.xml of your WAR

You must add the weblogic.servlet.JSPClassServlet class (instead of JSPServlet) to your Web application’s web.xml file. This makes WebLogic Server not look at the JSP source code at all. This implies that you can remove the JSP source code from your application after precompiling.

Example:

<servlet>
    <servlet-name>JSPClassServlet</servlet-name>
    <servlet-class>weblogic.servlet.JSPClassServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>JSPClassServlet</servlet-name>
    <url-pattern>*.jsp</url-pattern>
</servlet-mapping>

More information about the weblogic.servlet.JSPClassServlet class can be found here.

Comments are closed.