Tomcat JSP production configuration
More info at
Tomcat JSP config
When using Jasper 2 in a production Tomcat server you should consider making the following changes from the default configuration.
- development:To disable on access checks for JSP pages compilation set this to false.
- genStringAsCharArray:To generate slightly more efficient char arrays, set this to true.
- modificationTestInterval:If development has to be set to true for any reason (such as dynamic generation of JSPs), setting this to a high value will improve performance a lot.
- trimSpaces:To remove useless bytes from the response, set this to true.
- reloading:Should Jasper check for modified JSPs?
- keepgenerated:Should we keep the generated Java source code for each page instead of deleting it
- checkInterval:If development is false and reloading is true, background compiles are enabled. checkInterval is the time in seconds between checks to see if a JSP page needs to be recompiled. Default 300 seconds.
- modificationTestInterval:Checks for modification for a given JSP file (and all its dependent files) will be performed only once every specified amount of seconds. Setting this to 0 will cause the JSP to be checked on every access. Default is 4 seconds.
This is all configured in tomcat's conf/web.xml which is applied to all web.xml files for all apps.
Modify in
$TOMCAT_HOME/conf/web.xml:
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>development</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>genStringAsCharArray</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>trimSpaces</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>reloading</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>keepgenerated</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>checkInterval</param-name>
<param-value>99999</param-value>
</init-param>
<init-param>
<param-name>modificationTestInterval</param-name>
<param-value>99999</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>