aspose file tools*
The moose likes Servlets and the fly likes two servlet filters how to bypass second one Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "two servlet filters how to bypass second one" Watch "two servlet filters how to bypass second one" New topic
Author

two servlet filters how to bypass second one

John El
Greenhorn

Joined: Jun 10, 2008
Posts: 8
I have two filters, FilterA & FilterB, but I want FilterA to decide whether or not to run FilterB.
I saw a similar post from 3 years ago
http://www.coderanch.com/t/361028/Servlets/java/two-servlet-filters-bypass-second
but the reply doesn't suite my situation. I don't have access to FilterB, I only have access to FilterA.

Any ideas?
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

Originally posted by John El:
I don't have access to FilterB, I only have access to FilterA.

I'm not sure what this means. Does it mean that you cannot modify FilterB's code?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mohd Fuzail
Ranch Hand

Joined: Feb 20, 2002
Posts: 107
I think John wants to decide at runtime whether he wants to execute Filter B or not and this decision he needs to make from Filter A code
[ June 11, 2008: Message edited by: Mohd Fuzail ]

Being defeated is often a temporary condition. Giving up is what makes it permanent.
John El
Greenhorn

Joined: Jun 10, 2008
Posts: 8
You're both right. I cannot modify FilterB's code and I want to decide at runtime whether or not to run FilterB.

The solution is to extend FilterB, then inside FilterBExtended decide whether or not to call super.doFilter.

However; that solution just led to another problem...I'm trying to trap an error inside the filter, but it seems the error occurs deeper in the chain, and may not be reasonably trappable.

Thanks
saurabh mehta
Greenhorn

Joined: Oct 17, 2006
Posts: 1
[Edit: thread hi-jack removed. Please ask your questions in a new topic]
[ June 23, 2008: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: two servlet filters how to bypass second one