jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: [servlet-spec users] SERVLET_SPEC-52

From: Mark Thomas <markt_at_apache.org>
Date: Wed, 09 Jan 2013 10:02:49 +0000

On 09/01/2013 01:01, Shing Wai Chan wrote:
> I am looking at http://java.net/jira/browse/SERVLET_SPEC-52
> Clarify behaviour when the same filter is matched by several
> filter-mapping elements
>
> In 6.2.4 (p54), we have the following:
> If a filter mapping contains both <servlet-name> and <url-pattern>, the
> container must expand the filter mapping into multiple filter mappings
> (one for each <servlet- name> and <url-pattern>), preserving the order
> of the <servlet-name> and <url- pattern> elements.
>
> I plan to remove the "If" clause above as it is more consistence with
> the example immediately following the paragraph.
> So, we will have the following:
> The container must expand the filter mapping into multiple filter
> mappings (one for each <servlet- name> and <url-pattern>), preserving
> the order of the <servlet-name> and <url- pattern> elements.
>
> Please let me know your comments.

I'm still not sure what the expected behaviour is. I would like to see a
clear definition of what happens if a request matches multiple URL
patterns for the same filter. Specifically:
- How many times is the filter added to the filter chain? Just once or
once for every mapping that the request matches?
- If it is added just once, at what point is it added? The first match?
The last match? What if there are both servlet-name and url-pattern matches?

My own preference is that the filter is added just once using the first
match that is found. Subsequent matches to that filter are then ignored
for that request.

Mark