| 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
|
|
|
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]
|
 |
 |
|
|
subject: Servlet Filter Confusion
|
|
|