Cacheing
Cacheing

Reputation: 3481

servlet filter mapping overlap

I have two filters. And the url-pattern are respectively:

<filter>
    <filter-name>ListFilter</filter-name>
    <filter-class>mypackage.ListFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ListFilter</filter-name>
    <url-pattern>/list.jsp</url-pattern>
</filter-mapping>

<filter>
    <filter-name>AllFilter</filter-name>
    <filter-class>mypackage.servlet.AllFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>AllFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Then how will the two filters work if user access list.jsp?

Upvotes: 1

Views: 569

Answers (2)

Masudul
Masudul

Reputation: 21981

Then how will the two filters work if user access list.jsp?

The answer of this question is following image:

More than one Filter Mapping

For details go to this tutorial

Upvotes: 1

Thilo
Thilo

Reputation: 262842

All filters will get applied, in the order they are defined in web.xml.

For servlets, obviously only one can be executed, and this will be the most specific match.

Upvotes: 0

Related Questions