Summary: | Allow Context without real docbase in embedded Tomcat | ||
---|---|---|---|
Product: | Tomcat 8 | Reporter: | Konstantin Kolinko <knst.kolinko> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | ||
Priority: | P2 | ||
Version: | 8.0.x-trunk | ||
Target Milestone: | ---- | ||
Hardware: | PC | ||
OS: | All |
Description
Konstantin Kolinko
2014-10-28 00:44:09 UTC
I think that docBase that is equal to the empty string can be treated specially as this "No doc base" case. I mean that in this case one needs to configure the resources (org.apache.catalina.webresources.StandardRoot) so that no files are served. I think that now there is a risk that somebody will be unwillingly serving files from appbase if one specifies <Context docBase=""/> . If anybody really wants to serve files from appbase directory, one can use "." or an absolute path. Alternatively, add one-argument method to Tomcat class as public Context addContext(String contextPath) and perform all configuration of StandardRoot programmatically. In this case we can avoid special processing of docBase="". I'm leaning towards treating a docBase value of "" as invalid and using null to signal that a docBase on the file system is not required. I need to do some testing of this. I envision a caveat with ContextConfig.fixDocBase(). The fixDocBase() method replaces null docBase with one calculated from path, (new ContextName(path, context.getWebappVersion())).getBaseName(). Using null in tomcat.addContext(path, null) is indeed a good API. (Maybe add a single-argument Tomcat.addContext(path) for this use case). I don't see a need to change ContextConfig. That is not intended for use in embedding. If it was used it would only be used when there was a docBase on the filesystem. This has been fixed in 8.0.x for 8.0.15 onwards. |