3

I saw this answer that suggests to add <absolute-ordering>.

I am using tomcat 7.0.29 and have a few filters which are all defined like this: (not in web.xml)

@WebFilter(filterName = "SessionFilter",  servletNames = { "Jersey Web Application" })
public class HibernateSessionRequestFilter implements Filter {

Since I want the session filter to invoked before a filter called authenticationfilter, I added the following to web.xml between <web-app> tags.

<absolute-ordering>
      <name>SessionFilter</name>
      <name>AuthenticationFilter</name>
</absolute-ordering>

However, it doesn't work and authentication filter is executed BEFORE session filter.

Why?

Community
  • 1
  • 1
Dejell
  • 13,947
  • 40
  • 146
  • 229

1 Answers1

9

Reading the specification, absolute-ordering is used to order the loading of web fragments, not of servlet filters.

To fix the ordering of your filters, see the accepted answer in the question you linked to.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • Thanks. so why did the answer get so many votes up if the question was regarding filters and not web fragments? – Dejell Jun 02 '13 at 12:43
  • Good question. People probably upvoted blindly, without actually knowing or checking the answer was correct, or without reading the question carefully. – JB Nizet Jun 02 '13 at 12:45