• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Can a Filter block downstream processing ?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .


 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Always avoid anything labeled a "trick".
 
Ranjeetitm Singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice , Problem solved
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Don't misinterpret my words, I meant the same as you.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ranjeetitm Singh wrote:
Don't misinterpret my words, I meant the same as you.


We be cool.
 
Master Rancher
Posts: 5059
81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Master Rancher
Posts: 5059
81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Oh..... Thanks Mike
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic