Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 303
Kyle Avatar asked Jan 23 '10 07:01

Kyle


People also ask

Can we have multiple filters in web xml?

Yes. You can. The order you placed in web. xml will execute.

What is filter what is its use list the different filter interfaces with their important methods?

A filter is an object that is invoked at the preprocessing and postprocessing of a request. It is mainly used to perform filtering tasks such as conversion, logging, compression, encryption and decryption, input validation etc. The servlet filter is pluggable, i.e. its entry is defined in the web.

What is filter and types of filter in Java?

javax.servlet. Interface Filter. public interface Filter. A filter is an object that performs filtering tasks on either the request to a resource (a servlet or static content), or on the response from a resource, or both. Filters perform filtering in the doFilter method.


1 Answers

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

like image 135
Bozho Avatar answered Oct 21 '22 07:10

Bozho