aspose file tools
The moose likes Servlets and the fly likes Servlet Filter Confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Servlet Filter Confusion" Watch "Servlet Filter Confusion" New topic
Author

Servlet Filter Confusion

Ram Chhabra
Ranch Hand

Joined: Jan 07, 2008
Posts: 48
Hi,

I have created one filter. What i want that once control come to Filter, i need to do some validations and if it passes that validation then only i need to call chain.doFilter(res, req) but if validation fails then i don't want that request goes to servlet.

Can i send response from Filter only to client, without going to specific servlet.?

Thanks
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
I think you can do it this way...



Regards,
Vishwa


Blog
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
Yes. you should be able to control if the filter should continue the response or not.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Ram Chhabra
Ranch Hand

Joined: Jan 07, 2008
Posts: 48
Thanks for your reply. Inspite of sending to error page, is it ok to create the Response object and send back to client from filter only.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56549
    
  14

I would not generate output in a filter -- that's not its intent. Rather forward or redirect to whatever resource (JSP or servlet) will gneerate the desired response.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Filter Confusion
 
Similar Threads
OK to read the request body within a filter?
javascript-AJAX regarding
Interview question: What's the difference between and Servlet and Filter?
Spring portlet MVC forms, multipart data and servlets?
Filter configuration?