Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can a Filter block downstream processing ?  RSS feed

 
Ranjeetitm Singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a confusion in Filters . Is it possible for a filter to explicitly block all downstream processing ( by all other filters and
resource processors)

What I mean is ,if there are say 3 filters all applied on Servlet, in order
Filter_1 -------> Filter_2 -----> Filter_3 ------> Servlet


then is it possible that Filter_2 blocks downstream processing by Filter_1 .


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Filter 1 is called prior to filter 2 so how could it possibly block filter 1?
 
Ranjeetitm Singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bibeault, i also agree with you but i read it in IBM Developers Work under
the heading "Filtering Tricks for your Tomcat" by Sing Li
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always avoid anything labeled a "trick".
 
Ranjeetitm Singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice , Problem solved
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm serious. Sometimes you can do things that seem cool, but subvert the normal processing of the container. These should be avoided as they are frequently fragile, and always confusing.
 
Ranjeetitm Singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Don't misinterpret my words, I meant the same as you.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranjeetitm Singh wrote:
Don't misinterpret my words, I meant the same as you.

We be cool.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Ranjeetitm Singh wrote:Hi all,
I have a confusion in Filters . Is it possible for a filter to explicitly block all downstream processing ( by all other filters and
resource processors)

What I mean is ,if there are say 3 filters all applied on Servlet, in order
Filter_1 -------> Filter_2 -----> Filter_3 ------> Servlet

then is it possible that Filter_2 blocks downstream processing by Filter_1 .

No. Filter 1 is called prior to filter 2 so how could it possibly block filter 1?

It seems to me that filter 1 is upstream of filter 2, and filter 2 is downstream of filter 1. So 1 can block 2, but 2 can't block 1. Which means that (going back to the original form of the question before it was inverted): yes, it's possible for a filter to block downstream processing. It's not possible to block upstream processing. A quick Google found the article mentioned by the original poster, and it seems to confirm this usage: "calls on upstream filters are always on the stack, waiting for downstream calls to return". So of course an upstream filter can block downstream processing, but not vice versa. The article was written in 2001, when filtering was new, to some people. What it describes is not a "trick" - it's basic use of filters. The original poster just interpreted "upstream" and "downstream" differently than what was meant in the article.
 
Ranjeetitm Singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike ,
Do you mean to say that if they are in order like.


request
Client --------------- Filter_1 ----------- Filter_2 ------------ Filter_3 --------- Servlet


response
Client ------------- Filter_1 ------- Filter_2 --------- Filter_3 ------- Servlet


Then in second figure Filter_2 can stop processing by Filter_1,
If you mean the same then please tell how...
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I mean that filter 1 can block downstream processing by filter 2. And that's all the original article meant. You've apparently inverted what was meant by "upstream" and "downstream".
 
Ranjeetitm Singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Oh..... Thanks Mike
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!