tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Koen Serneels" <>
Subject Registering Filters via API: isMatchAfter behaves weird
Date Wed, 04 Apr 2012 18:00:47 GMT


I came across weird behavior using the JEE Servlet 3.0 API for adding
Filters with Tomcat 7.0.26
When I map two filters on the same URL and I use the "isMatchAfter"
attribute I would expect the filter having "isMatchAfter set to true to be
invoked last.

For example:


FilterRegistration.Dynamic registration1 =
servletContext.addFilter("filter1", new Filter1());

registration1.addMappingForUrlPatterns(null, true, "/Filter");

FilterRegistration.Dynamic registration2 =
servletContext.addFilter("filter2", new Filter2());

registration2.addMappingForUrlPatterns(null, false, "/Filter");


Filter1 prints "Filter1" to console when invoked, Filter2 prints "Filter2"
to console when invoked.

The "isMatchAfter" of filter one is set to true, which should mean it should
be invoked last when another filter is mapped on the same URL.

So I would expect that filter one is invoked AFTER filter two. This seems to
be inversed, Tomcat output:




I verified the example but with Glassfish 3.1.1 and this one delivered the
results as expected;


INFO: Filter2

INFO: Filter1


The flag does seem to have impact, because if I switch it: I set
isMatchAfter to false on filter one and isMatchAfter to true on filter 2 I
get this with tomcat:





So it looks like this flag was miss interpreted somehow and treated as a





  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message