How do web.xml filters work? Can you have two filters map to all pages (/*) and specify the order?

Kyle picture Kyle · Jan 23, 2010 · Viewed 25.2k times · Source

I want to use Spring Security, and it says to map the filter to /***. But I already have a filter mapped to /*, which is the Tuckee URLRewrite filter.

Is it possible to map two filters to the same thing, and also is there a way to specify the order that the filters get called?

Answer

Bozho picture Bozho · Jan 23, 2010

Yes, you can:

The servlet 2.5 xsd:

The order in which filters are invoked is the order in which filter-mapping declarations that match a request URI for a servlet appear in the list of filter-mapping elements

i.e. it depends on the order of your <filter-mapping> elements in the web.xml