On Fri, Aug 1, 2008 at 1:39 PM, André Warnier <[EMAIL PROTECTED]> wrote:

> Can one dynamically disable a servlet filter under some conditions, from
> within another preceding filter ?

> And suppose that I control the code of filter A but have no access to the
> code of filter B, and filter B has no parameter allowing to make it
> conditional.
>
> Can I, from within filter A, which gets to see the request first, based on
> some characteristic of the request, decide that for this request I want to
> disable (or short-circuit or bypass) filter B ?

You could /probably/ -- untested conjecture -- break the FilterChain at
that point by forwarding to a URL for which Filter B wasn't applied (or
was applied only to a REQUEST rather than FORWARD.

Or possibly hack the FilterChain itself -- non-portable at best.

The first is probably more reasonable :-)  Read the 2.5 Servlet Spec
chapter on Filters, if you haven't already.

> - and/or, suppose that for filter C I would also have access to the code,
> could I design some mechanism whereby filter A could "tell" filter C not to
> do anything for this request ?

That's an easy one: just have Filter A add a request attribute that
Filter C uses to determine what action to take.

if ( ((String)request.getAttribute("askNicely")).equals("please") ) {
...

HTH!
-- 
Hassan Schroeder ------------------------ [EMAIL PROTECTED]

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to