Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify filter priorities in java web apps?

Hello I wish I could define two filters like this

  <filter-mapping>
    <filter-name>SecurityFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>ContextFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

with the same pattern /* in my web.xml file, and I wish I could be sure the SecurityFilter will be executed before the other. Is there a way to do so?

like image 757
Aldian Avatar asked Mar 23 '26 07:03

Aldian


1 Answers

You just did. From Sun's 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.

like image 105
Jacob Mattison Avatar answered Mar 26 '26 08:03

Jacob Mattison