jakartaee / jakartaee/servlet

Clarify behaviour when the same filter is matched by several filter-mapping elements

Open
#52 6 comments 0 reactions 0 assignees View on GitHub
Candidate4NextRelease Question
Dominant language
Java
Stars
325
Forks
112
PR merge metrics
No merged PRs in 30d

Description

The chapter 6.2.4 Configuration of Filters in a Web Application defines how a container builds the chain of filters to be applied to a particular request URI.

My question is what should happen if there are several matching filter-mappings for the same filter (either by different s, or by an and a ):
whether
a) the filter has to be called several times, as many as how many matching s are there.
or
b) the filter has to be called only once, honoring the first filter-mapping that matches,

An example:

filterA
/view/*
*.do

If the requested URI is "/view/bar.do", does the filter have to be called twice?

My own reading is that "a)" (multiple calls) is what is implied by that chapter, but I would like this to be mentioned explicitly.

If actually the requirement is "b)" (single call), then I would like someone to clarify what mapping takes priority when there is both an url-pattern and a servlet-name match. As the servlet-name mappings are processed first, it seems that the servlet-name mapping wins, but it is confusing as those filters are positioned later in the resulting filter chain than the ones mapped by url-patterns.

In Tomcat 7 the "b)" behaviour was implemented but with url-patterns having the priority, stemming from the following issue:
[https://issues.apache.org/bugzilla/show_bug.cgi?id=49922](https://issues.apache.org/bugzilla/show_bug.cgi?id=49922)

Contributor guide

Open the contributing guide

Research direction

Start with chapter 6.2.4, then compare its filter-mapping wording with the Tomcat 7 behavior and the referenced Bugzilla issue. Clarify whether overlapping mappings invoke a filter once or multiple times, and document the priority when URL-pattern and servlet-name mappings both match.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.