users@servlet-spec.java.net

[servlet-spec users] [jsr369-experts] Re: [73-getMapping] PROPOSAL

From: Mark Thomas <markt_at_apache.org>
Date: Wed, 8 Feb 2017 22:40:02 +0000

On 08/02/17 20:58, Edward Burns wrote:
> MT> Much clearer. Many thanks. +1 from me.
>
> EB> Aside from the below mentioned changes to the sketch provided by Arjan,
> EB> I have a question. Does it make sense to allow the caller to discover
> EB> if the mapping was invoked via a Servlet vs. a Filter? If so, how about
> EB> adding a method to Mapping boolean isServlet()?
>
> MT> How would that work? If you call a method on the HttpServletRequest then
> MT> the request will have been mapped to exactly one servlet and to 0 to
> MT> many filters. How do you determine which mapping to return? Do you
> MT> return them all?
>
>>>>>> On Tue, 15 Sep 2015 08:11:56 -0700, Edward Burns <edward.burns_at_oracle.com> said:
>
> EB> Let's just leave that out, then.
>
> I have updated the proposal and implemented it on top of GlassFish
> trunk, but it is not yet committed.
>
> I addressed the Filter and Listener issue as follows:
>
> HttpServletRequest.getMapping():
>
> If called from a Servlet, return the Mapping by which this
> HttpServletRequest was invoked, otherwise return a Mapping equivalent
> to the one specified for the default implementation. Each invocation
> of this method must return a fresh instance of Mapping. The
> implementation must retain no reference to the returned
> Mapping. Servlet 4.0 compliant implementations must override this
> method.

Changing the behaviour based on which code is making the call will break
the intended use cases.

Every request is mapped to a servlet. getMapping() should return the
current servlet mapping regardless of where the call originates from.

Mark


>
> Implementation Requirements:
>
> The default implementation returns a Mapping that returns the empty
> string for the match value and pattern and MappingMatch.UNKNOWN for
> the match type.
>
> The full API can be browsed at
>
> https://maven.java.net/service/local/repositories/snapshots/archive/javax/servlet/javax.servlet-api/4.0.0-b03-SERVLET_SPEC-73-SNAPSHOT/javax.servlet-api-4.0.0-b03-SERVLET_SPEC-73-20170208.204929-1-javadoc.jar/!/javax/servlet/http/HttpServletRequest.html#getMapping--
>
> ACTION: Please reply by close of business GMT-0800 Friday 10 February or
> I'll run with the above proposal.
>
> Thanks,
>
> Ed
>