• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chain Of Responsibilty question

 
VamC Poondla
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a good practice to have a filter which does a remote call and based on the result, redirect the request or massage the request with more data etc.

I am feeling not. But it is a mere gut feel opinion. So, I want the forum to express their opinion.
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a good idea to forward to a specific servlet or JSP from a filter. If you do that, you increase the coupling between the filter and the specific servlet / JSP. Filters are meant to be generic and in a good design, they should have no idea about which filter or servlet comes next in the chain. Hence, good design should preserve this loose coupling. Filters are meant to customize the request and response and should normally not take important decisions as redirecting to a specific servlet / JSP . If you introduce such dependencies, you'll have to end up changing code if the flow changes later. The main purpose of filters is to avoid such code changes and handle them declaratively in the DD

Let me know what you if you have a second opinion
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic