[jsr369-experts] Re: SERVLET_SPEC-137: Allow context root

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Mon, 31 Aug 2015 17:15:37 -0700

On Tue, 25 Aug 2015 17:54:05 -0700, Shing Wai Chan
<shing.wai.chan_at_oracle.com> wrote:

SWC> I am looking at https://java.net/jira/browse/SERVLET_SPEC-137
SWC> (“Allow context root”)

SWC> In Java EE ear application, one can configure the context-root in
SWC> For war, there is no such configuration in web.xml.

SWC> Most servlet containers take default context-root = name of the
SWC> And there are different solutions to configure the context-root as
SWC> i) configure context-root through the proprietary descriptors.
SWC> For instance glassfish-web.xml in GlassFish and weblogic.xml in
SWC> ii) configure context-root at the time of deployment without
editing descriptors in the war.
SWC> iii) support the configuration of context-root “after” the
deployment through administration tool.

SWC> I am considering adding a context-root element in web.xml.
SWC> Any comments?

>>>>> On Wed, 26 Aug 2015 15:42:57 -0700, Mark Thomas
<markt_at_apache.org> said:
MT> I don't like it.

MT> Web applications are meant to be independent of the context path they
MT> are deployed to.

The proposed <context-root> provides a default context-root other than
war name.
(Just consider the maven generated web application as mentioned by Stuart.)

MT> Containers already provide container specific ways to specify the
MT> context path as part of the deployment process (which is where the
MT> context path should be defined).

Also, I notice that different vendors provide this feature in their own
deployment descriptors.
It would good to provide a standard, and hence a portable way, to do this.

MT> I'm pretty sure if this features makes it into Servlet 4.0 (and I am -1
MT> on that happening) then Tomcat is simply always going to ignore whatever
MT> is set.

If this is a Servlet 4.0 feature, there is most likely a Servlet TCK
assertion for this.
Mark, can you help us understand why you are taking such a strong
position against it
as a representative for the hugely important Tomcat community?

>>>>> On Tue, 25 Aug 2015 18:21:39 -0700, Justin Lee
<jlee_at_antwerkz.com> said:

JL> I think web.xml is probably not the *greatest* place for that. It's
a static resource embedded in
JL> the deployment artifact that people would have to explode to change
and then rebundle. I've seen
JL > (and used) context.xml, e.g., to allow for simultaneous deployments
of wars. I haven't found
JL > matching war names to context roots is really a problem for single

>>>>> On Wed, 26 Aug 2015 11:09:27 -0700, Shing Wai Chan

SWC> The usage of context.xml mentioned below is similar to case (iii)

SWC> The proposed <context-root> in web.xml provides a context-root for
the application.
SWC> (We can clarify that the default context-root is name of the
application if <context-root>
SWC> is not present in the web.xml.)
SWC> This can still be overridden by (ii) and (iii) below if it is

According to my understanding, most containers take the war name as the
Defining the default value (without <context-root>) may cause backward
compatible issue.
So, we need to take a closer look at this.

>>>>> On Wed, 26 Aug 2015 19:37:09 -0700, Stuart Douglas
<sdouglas_at_redhat.com> said:
SD> I like the idea. At the moment there is no standard way to do this
unless your way is deployed in an ear.

SD> I don't really think the arguments against it have any weight, if a
container specific mechanism
SD> is also used then it will just SD> override the name in web.xml
(same as what happens anyway
SD> for the default name). Just because it is not the ideal approach for
every situation does not mean
SD> that we should not offer it at all.

SD> An obvious example of where this would be useful is the default
artefact name that maven generates,
SD> ${artefact}-${version}.war, at the moment there is no standard way
to change the context path to not
SD> include the version number.

Yes, maven generated web application is a good example.

>>>>> On Wed, 26 Aug 2015 22:44:42 -0700, Greg Wilkins
<gregw_at_webtide.com> said:
GW> I agree that web.xml is not the best place for this, but then there
are lots of things that shouldn't
GW> really be in web.xml.

GW> However, perhaps if instead of a specific configuration, if it were
a default that is clear that
GW> it can be overridden by other container mechanism?

GW> Something like:

GW> <default-context-path>/</default-context-path>

GW> and it would be used IFF there was no other explicit configuration
for the context path in the
GW> container (including container specific configuration) and there was
no other context already
GW> deployed at that path.

Yes, we should allow the container to override the context root
We can discuss more on the XML element name once we agree to have this

Before we move forward, I would like to try to get the Tomcat community
on board.
Mark, can you please help me understand your position?

       Shing Wai Chan