Reputation: 2765
Consider the following filter mappings in my web.xml
<filter-mapping>
<filter-name>rememberMeCookieFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>mustBeSignedInFilter</filter-name>
<url-pattern>/private/*</url-pattern>
</filter-mapping>
As far as I understand from the tests I made, if I go to /private/account.jsp
, the mustBeSignedInFilter will always be executed first (from what I could read, it's because the path is more specific). I need the rememberMeCookieFilter to be executed first.
How do I do that?
Upvotes: 1
Views: 542
Reputation: 1109875
You're confusing filter mappings with servlet mappings. All filters matching the URL are executed in the same order as their filter mappings are been specified in web.xml
. So swap the filter mappings and it'll work as you expected.
<filter-mapping>
<filter-name>mustBeSignedInFilter</filter-name>
<url-pattern>/private/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>rememberMeCookieFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Upvotes: 1