what is the exact order of filters?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

what is the exact order of filters?

Johan Compagner
Hi
here we have a case: 51754 – Tomcat7 filters from conf/web.xml are applied
after filters defined in WEB-INF/web.xml (apache.org)
<https://bz.apache.org/bugzilla/show_bug.cgi?id=51754>

that already says that the conf/web.xml are later then WEB-INF/web.xml

is it so that the order is something like


WEB-INF/web.xml
annotations based once
conf/web.xml

?

I am also not sure what the spec says about this mix

--
Johan Compagner
Servoy
Reply | Threaded
Open this post in threaded view
|

Re: what is the exact order of filters?

Mark Thomas-2
On 15/01/2021 16:00, Johan Compagner wrote:

> Hi
> here we have a case: 51754 – Tomcat7 filters from conf/web.xml are applied
> after filters defined in WEB-INF/web.xml (apache.org)
> <https://bz.apache.org/bugzilla/show_bug.cgi?id=51754>
>
> that already says that the conf/web.xml are later then WEB-INF/web.xml
>
> is it so that the order is something like
>
>
> WEB-INF/web.xml
> annotations based once
> conf/web.xml
>
> ?
>
> I am also not sure what the spec says about this mix

You need to read section 8.2.3 of the servlet specificaiton

<quote>
If the order in which the listeners, servlets, filters are invoked is
important to an application then a deployment descriptor must be used.
Also, if necessary, the ordering element defined above can be used. As
described above, when using annotations to define the listeners,
servlets and filters, the order in which they are invoked is unspecified.
<quote>

Entries in the global web.xml files will be added after those from the
application web.xml

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: what is the exact order of filters?

Johan Compagner
> You need to read section 8.2.3 of the servlet specificaiton
>
> <quote>
> If the order in which the listeners, servlets, filters are invoked is
> important to an application then a deployment descriptor must be used.
> Also, if necessary, the ordering element defined above can be used. As
> described above, when using annotations to define the listeners,
> servlets and filters, the order in which they are invoked is unspecified.
> <quote>
>
> Entries in the global web.xml files will be added after those from the
> application web.xml
>
>
yes thats what i was testing also
But where are then annotations coming in?
I can't find that.
And i mean together with a web.xml in conf and a web.xml in web-inf where
there are also definitions of filters and mappings..

It seems to me that it is:

WEB-INF/web.xml (these do have order between them)
annotations (unordered)
conf/web.xml (these do have order between them)

or is that just an tomcat implementation? that other containers don't
really have to follow?