> If ServletContext.getContext(String) is actually supposed to perform
> prefix-mapping, then it explains why getContext("/ROOT") worked for
> you.
> getContext("/ROOT") worked just because getContext("/foobar") returns
> the ROOT context when there is no "foobar" application. There is
> nothing special in the name "/ROOT" here. Your "issue 1" and "issue
> 2" are the same.
Agreed. I don't think that "/ROOT" is inherently meaningful. It is simply a
prudent choice when looking for the ROOT context because it is a path that
would be handled by the root context and it is also unlikely to match the
context path of another application.
> 2. I think this needs a clarification from Servlet EG at least to fix
> their Javadoc. [1]
> As of now,
> a) There is no explicit mention of prefix matching in [1].
> It says "uripath - a String specifying the context path of another web
> application in the container."
> b) It says "The given path must be begin with /", but context path of
> the default context is an empty string (per
> ServletContext.getContextPath()).
> The prefix matching has annoying consequence that it may return a
> different web application, not the one that you expect.
> [1]
> http://docs.oracle.com/javaee/7/api/javax/servlet/ServletContext.html#getContext%28java.lang.String%29
Not that I disagree with getting clarification from Servlet EG, but this is a
major change in functionality. If there is a decision to make this kind of
change in response to a change in the spec, it should be done in a major
release, not a patch. As it is, we are going to have to modify the Supported
Platforms Matrix for our product and specifically exclude a couple of patch
releases of Tomcat 7 and 8. I don't want to have to exclude all future patches
of Tomcat 8.
Regards,
Doug Forrest