Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Interrupting a filter

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following scenario :

A 3rd party filter (and therefore not modifyable through me) usually handles all requests and responses coming and going to a certain path like

/tobefiltered/*

On certian occasions I just want to filter to request data , but not the response ... Is there any way to intererupt the filterchain so that the response can be sended out without this filter handling it ?

Best regards !
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you can interrupt the filter chain. But you could implement your own filter that is invoked for the same path, and put your filter in the chain prior to 3rd party filter. Your filter would receive the response from the 3rd party filter and could then manipulate the response as desired.

Dave
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A 3rd party filter (and therefore not modifyable through me) usually handles all requests and responses coming and going to a certain path like



If you can reconfigure the filter chain, David's approach should work. Do you have access to web.xml ?
 
crix madine
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I modify the HttpServletRequest ServletPath through a filter ? I am not quite sure where to find it, the object itself only provides a getter ...
 
David Howie
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with any way to change the servlet path, why would you want to do so? If you do not want the 3rd party filter to be invoked than you can bypass it by having your filter skip invocation of the FilterChain.doFilter method. Of course doing so would also mean that the servlet that is to handle the request will not be invoked. The following is my understanding of the flow:

Web Container --> Your Servlet Filter --> 3rd Party Servlet Filter --> Servlet

The way the chain is continued is by each servlet filter invoking the doFilter method on the FilterChain instance that is passed to the filter's doFilter method. Once the servlet has completed processing then the flow returns back up the chain.

Dave
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic