Bug 52924 - Add support for per-application JSP compile configuration in Tomcat 6, 7
Summary: Add support for per-application JSP compile configuration in Tomcat 6, 7
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Jasper (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2012-03-15 21:36 UTC by Nick Williams
Modified: 2017-07-04 19:21 UTC (History)
0 users

Sample tomcat-web.xml file, similar to glassfish-web.xml file (506 bytes, text/xml)
2012-03-15 21:36 UTC, Nick Williams

Note You need to log in before you can comment on or make changes to this bug.
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.