2

I have a developement server that was on Tomcat 6. I just installed Tomcat 8, and noticed that it no longer recompiles JSPs on page hit. What do I have to change in server.xml to get it to recompile them on page hit?

Note: Someone pointed me to http://tomcat.apache.org/tomcat-8.0-doc/config/loader.html but I don't think that answers the question because I don't care about reloading jars or class files under /WEB-INF/classes/ or /WEB-INF/lib, just recompiling JSPs.

And if for some reason this can't be done in Tomcat 8, can it be done in Tomcat 7?

developerwjk
  • 263
  • 1
  • 3
  • 8

1 Answers1

5

Tomcat 8 and 7 uses the Jasper 2 JSP Engine. One of changes was made in this version is:

Background JSP compilation
If you make a change to a JSP page which had already been compiled Jasper 2 can recompile that page in the background. The previously compiled JSP page will still be available to serve requests. Once the new page has been compiled successfully it will replace the old page. This helps improve availability of your JSP pages on a production server.

To control this behavior you can use the following parameters (in $CATALINA_BASE/conf/web.xml):

checkInterval - If development is false and checkInterval is greater than zero, background compiles are enabled. checkInterval is the time in seconds between checks to see if a JSP page (and its dependent files) needs to be recompiled. Default 0 seconds.

development - Is Jasper used in development mode? If true, the frequency at which JSPs are checked for modification may be specified via the modificationTestInterval parameter.true or false, default true.

See more: Jasper 2 JSP Engine How To

Federico Sierra
  • 3,589
  • 1
  • 20
  • 26
  • 1
    How do I configure this for a specific application, rather than changing it globally? – nsane Mar 02 '16 at 18:14
  • @nisargshah95 If your web application needs specific settings, copy the declaration of JspServlet in the `conf/web.xml` file into your own `WEB-INF/web.xml` and adjust it. – Federico Sierra Mar 02 '16 at 19:42
  • 1
    Do I need to copy all the settings from `JspServlet` declaration and then append my own to it or only keep the settings that I want to add in `WEB-INF/web.xml` and tomcat will automatically append it to its own `JspServlet` settings? – nsane Mar 03 '16 at 04:25
  • I have a local tomcat (xamp) and this development parameter is not set. Still tomcat recompiles the JSPs when they change. – Marc Sep 18 '17 at 11:04