On Wed, 22 Jan 2003, Erik Price wrote:

> Date: Wed, 22 Jan 2003 15:37:21 -0500
> From: Erik Price <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: Re: using multiple filters
>
>
>
> Craig R. McClanahan wrote:
>
> >>Is testing the URL the most elegant way to achieve the former
> >>(determining when the SecurityFilter should be in effect and when it
> >>shouldn't)?  And to use the latter (a form validation filter) do I need
> >>to register it in the same FilterChain as the the SecurityFilter?  Or
> >>can there be two separate, disparate filters for a given resource?
> >>
> >
> >
> > You can have any number of filters mapped to the same resources -- the
> > container assembles the filter chain for you, so you don't need to worry
> > about that.
>
> I thought that the FilterChain is the last argument to my doFilter
> method call in my filter?

Yes, but it is the container's job to configure which filters are
included.

>  So then how do I specify which filter gets
> executed first?
>
>

The precise rules are listed in Section 6.2.4 of the Servlet Spec.
Basically, the container will:

* Find all the matching URL-mapped <filter-mapping> entries, and
  add the corresponding filter, in the order that these <filter-mapping>
  elements are in the web.xml file.

* Find all the filter-name-matched <filter-mapping> entries, and
  add the corresponding filter, in the order that these <filter-mapping>
  elements are in the web.xml file.

* The last filter in the constructed chain is rigged up so that
  calling chain.doFilter() from there will actually invoke the
  servlet.

So, you control the order filters are invoked in by managing the order of
your <filter-mapping> elements.

>
> Erik
>

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to