File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Filter Confusion

 
Ram Chhabra
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 331
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can do it this way...



Regards,
Vishwa
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. you should be able to control if the filter should continue the response or not.
 
Ram Chhabra
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64183
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic