File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes How to configure Filter so that it will only process request but not response 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 » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "How to configure Filter so that it will only process request but not response" Watch "How to configure Filter so that it will only process request but not response" New topic
Author

How to configure Filter so that it will only process request but not response

James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

I want to know how to configure a filter so that it will process only the incoming request but not the response going from the server.
Any suggestion or corresponding links would be helpful


I read in Filter docs that we can have "A filter is an object that performs filtering tasks on either the request to a resource (a servlet or static content), or on the response from a resource, or both"
Thanks


SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

In your filter after you call filter.doFilter();, don't do any further processing. Filters are not separately applied to request and response...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

I am sorry to say that i did not understand when you said "don't do any further processing". Can you explain that ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you don't want to process the response, just don't write any code. You have to call "filter.doFilter()" and then after that don't do anything. Write zero lines of code. Return immediately. "Don't do anything" isn't really very complicated, but here's an example if you still need one:
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

Thanks for the reply...
suppose if i want to do the filter even when response is sent then what should i do ?
I am asking this because my filters are not called when response is sent (Even though i currently don't need this feature in my app i would like to know.)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

James filters are not called separately for request and response. When the book said request or response or both, this is what they meant

James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

Thanks Ankit, i got it this time...
Thank you , will get back if need(i guess i don't have to).
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 512
Hi James,

My 2 cents !!

Response Filters

Regds,
Amit
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

Thanks Amit , i got that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to configure Filter so that it will only process request but not response