Bug 53737 - Use ServletContext.getJspConfigDescriptor() in Jasper instead of XML-parsing of merged web.xml [PATCHES]
Summary: Use ServletContext.getJspConfigDescriptor() in Jasper instead of XML-parsing ...
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 8.0.x-trunk
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2012-08-18 00:54 UTC by Konstantin Kolinko
Modified: 2018-11-20 17:41 UTC (History)
0 users

Add support for JspConfig to JspC's ServletContext (24.30 KB, patch)
2013-06-29 23:03 UTC, Jeremy Boynes
Details | Diff
Add changes from r1377509 (49.56 KB, patch)
2013-07-04 18:42 UTC, Jeremy Boynes
Details | Diff
Incremental, adds merging of fragments and scanning using ServletContext (54.33 KB, patch)
2013-07-08 05:24 UTC, Jeremy Boynes
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2012-08-18 00:54:55 UTC
In Tomcat 7.0.29 in ContextConfig#webConfig() a merged web.xml file is serialized into String and is put as an attribute into ServletContext.

        String mergedWebXml = webXml.toXml();

Then in JspConfig#processWebDotXml() of Jasper it is parsed again from XML into objects.

It would be better to access the necessary configuration through Servlet 3.0 API methods such as ServletContext.getJspConfigDescriptor().
Comment 1 Mark Thomas 2012-08-26 20:30:06 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.30 onwards.
Comment 2 Mark Thomas 2012-08-26 22:48:53 UTC
The fix wasn't as simple as it first appeared due to having to support JspC. The original fix has been reverted pending a re-think.
Comment 3 Jeremy Boynes 2013-06-29 23:03:33 UTC
Created attachment 30504 [details]
Add support for JspConfig to JspC's ServletContext

Related to r1377509 (reverted), this patch adds support for identifying the effective version of an application and for setting up a JspConfigDescriptor for JspC that would match the one returned by a container at runtime.

This should mean that Mark's original change would also work in JspC, allowing the two implementations to be consolidated.

This patch does not yet attempt to merge in web-fragment.xml files as that functionality is not supported by the current JspC implementation either. I plan to add that later if this looks like a good way to go.

There is also some duplication with implementations in o.a.c.core. Jasper does not have any dependencies on catalina so I did not reuse those. However, these could potentially be moved to o.a.tomcat.util and shared.
Comment 4 Jeremy Boynes 2013-07-04 18:42:14 UTC
Created attachment 30533 [details]
Add changes from r1377509

Update previous patch to merge in changes from r1377509 that were reverted due to issues with JspC. This removes need for Jasper's compiler to parse a web.xml, instead relying on a ServletContext provided by the container or now by the JspC shell. Jasper's WebXml class was deprecated in r1377509, it is not longer referenced in Jasper and could be removed.

Ran test-bio with no failures, and ran JspC separately on a simple webapp to verify <jsp-config> is being handled (checked default-content-type is picked up from web.xml).

Patch still has todo's to add web-fragment support when JspC builds its ServletContext.
Comment 5 Jeremy Boynes 2013-07-08 05:24:05 UTC
Created attachment 30568 [details]
Incremental, adds merging of fragments and scanning using ServletContext

Increment on prior patch to add merging of jsp-config found in web-fragments.

Also change to JspC to scan for JSPs based on resources found in the ServletContext. This currently works just for resources in the main webapp but not for those in META-INF/resources in jars - work is still needed in JspCServletContext to map those.
Comment 6 Mark Thomas 2013-07-09 14:51:51 UTC
This has been partially fixed using a combination of the original fix, the patches here and patches from violetagg.

web-fragment and annotations are still TODO so the code is effectively in the same place funcitonaly as before the patch.
Comment 7 Mark Thomas 2013-12-07 21:33:49 UTC
Support for web fragments has been added.

Support for annotations is not required as they do not affect JspC.

Support for JSPs in resource JARs is still to do.
Comment 8 Mark Thomas 2018-11-20 17:41:09 UTC
Resource JAR supported added to:
- 9.0.x for 9.0.14 onwards
- 8.5.x for 8.5.36 onwards

7.0.x does not support resource JARs.