Bug 52924

Summary: Add support for per-application JSP compile configuration in Tomcat 6, 7
Product: Tomcat 6 Reporter: Nick Williams <nicholas>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Severity: enhancement    
Priority: P2    
Version: unspecified   
Target Milestone: default   
Hardware: All   
OS: All   
Attachments: Sample tomcat-web.xml file, similar to glassfish-web.xml file

Description Nick Williams 2012-03-15 21:36:35 UTC
Created attachment 28477 [details]
Sample tomcat-web.xml file, similar to glassfish-web.xml file

Some of the more popular application servers (GlassFish, WebLogic and WebSphere) provide easy methods for controlling JSP configuration parameters on a per-application basis.

Tomcat 7, for example, can run on Java 7, but the default JSP compile level is 1.6, and in order to support compiling JSPs for Java 7, you have to change the value of compileSourceVM and compileTargetVM for the entire server in $CATALINA_BASE/conf/web.xml (affects everything) or redeclare the JspServlet in your web.xml file (not portable to other application servers).

I propose a tomcat-web.xml file specification (similar to GlassFish 3.x's glassfish-web.xml file specification) that enables configuration of certain Tomcat-specific application properties. We can start off with just a few options and over time could make Tomcat much more powerful as we find other options to put in there.

I propose that the first setting supported in this file be a JSP compile level (1.5, 1.6, 1.7, etc.).

I propose that the second setting supported be the ability to precompile JSPs on application startup (a feature not currently supported without significant configuration/work).

I have attached a sample tomcat-web.xml file that could potentially be used (very similar to GlassFish equivalent).

It would be great if this could be added to Tomcat 6 AND Tomcat 7, but if Tomcat 6 is out of the question, go ahead and move this enhancement suggestion to Tomcat 7.

Maybe possible is that it supports only the JSP language level in Tomcat 6 and supports more in Tomcat 7?
Comment 1 Mark Thomas 2017-07-04 19:21:30 UTC
This has been implemented for Tomcat 9 and will be included in 9.0.0.M24 onwards.

/WEB-INF/tomcat-web.xml has exactly the same format as /WEB-INF/web.xml and works the same way as conf/web.xml. The full order of precedence is (highest priority first):
- /WEB-INF/web.xml
- /WEB-INF/tomcat-web.xml
- /conf/<engine>/<host>/web.xml.default
- /conf/web.xml

I'm not currently planning on back-porting this new feature.