Discussion:
Servlet 3.0, @WebFilter and ordering
Stevo Slavić
2011-02-08 09:31:28 UTC
Permalink
Hello Tomcat users,

Now that Tomcat 7 is out with Servlet 3.0 support, I've been trying
out new features it brings. In pre 3.0 servlet era, one would specify
filter in web.xml and order they are defined in the xml would
determine order filters would get applied. I don't see support for
ordering in @WebFilter annotation. Am I missing something?

I know one can now programatically register filters - not sure yet but
I guess order filters are programatically registered determines order
they will be applied. But if this is the only way to control ordering,
@WebFilter is (almost) useless, without support of additional
framework.

Not sure if this mailing list is correct destination for this kind of
question. I apologize, if it isn't.

Regards,
Stevo.
Mark Thomas
2011-02-08 19:48:26 UTC
Permalink
Post by Stevo Slavić
Hello Tomcat users,
Now that Tomcat 7 is out with Servlet 3.0 support, I've been trying
out new features it brings. In pre 3.0 servlet era, one would specify
filter in web.xml and order they are defined in the xml would
determine order filters would get applied. I don't see support for
No. You are not missing anything.
Post by Stevo Slavić
I know one can now programatically register filters - not sure yet but
I guess order filters are programatically registered determines order
they will be applied. But if this is the only way to control ordering,
@WebFilter is (almost) useless, without support of additional
framework.
Not sure if this mailing list is correct destination for this kind of
question. I apologize, if it isn't.
It is the right place to ask these sorts of questions but getting it
changed means contacting the Servlet EG.

Mark
Christopher Schultz
2011-02-08 20:52:40 UTC
Permalink
Stevo,
Post by Stevo Slavić
I don't see support for
I don't see anything that would allow an ordering to be specified.
Post by Stevo Slavić
But if [programmatically adding] is the only way to control ordering,
@WebFilter is (almost) useless, without support of additional
framework.
I agree.

I think the best thing to do is always use declarative configuration
through the use of web.xml, but then again, I detest annotations. :)

- -chris
Konstantin Kolinko
2011-02-09 06:46:26 UTC
Permalink
Post by Christopher Schultz
Post by Stevo Slavić
I don't see support for
I don't see anything that would allow an ordering to be specified.
Ordering is discussed in chapters 8.2.2 and 8.2.3 of the servlet 3.0 spec.

In 8.2.3 it is explicitly written:
"As described above, when using annotations to define the listeners,
servlets and filters, the order in which they are invoked is
unspecified"

Best regards,
Konstantin Kolinko
Remy Maucherat
2011-02-09 07:58:29 UTC
Permalink
On Wed, Feb 9, 2011 at 7:46 AM, Konstantin Kolinko
Post by Konstantin Kolinko
Post by Christopher Schultz
Post by Stevo Slavić
I don't see support for
I don't see anything that would allow an ordering to be specified.
Ordering is discussed in chapters 8.2.2 and 8.2.3 of the servlet 3.0 spec.
"As described above, when using annotations to define the listeners,
servlets and filters, the order in which they are invoked is
unspecified"
Well, but it is still defined a bit by the ordering of the JARs. But
within the JAR, the order of processing of @WebFilter is undefined,
which seems quite logical to me.
(If you need ordering, use a SCI or listener and add the filters
programmatically)

Rémy
Stevo Slavić
2011-02-09 08:49:41 UTC
Permalink
Thanks everyone,

Just wish there was an "Ordered" interface, or annotation, or
attribute of @WebXXX annotations to which ordering can be applied, so
that web.xml is not needed for such IMO basic feature.

Regards,
Stevo.
Post by Remy Maucherat
On Wed, Feb 9, 2011 at 7:46 AM, Konstantin Kolinko
Post by Konstantin Kolinko
Post by Christopher Schultz
Post by Stevo Slavić
I don't see support for
I don't see anything that would allow an ordering to be specified.
Ordering is discussed in chapters 8.2.2 and 8.2.3 of the servlet 3.0 spec.
"As described above, when using annotations to define the listeners,
servlets and filters, the order in which they are invoked is
unspecified"
Well, but it is still defined a bit by the ordering of the JARs. But
which seems quite logical to me.
(If you need ordering, use a SCI or listener and add the filters
programmatically)
Rémy
---------------------------------------------------------------------
Loading...