I had a doubt on when to use Intercepting filter pattern and Front Controller pattern
This is what my uderstanding correct me if i'm wrong anywhere,
Intercepting filter pattern:
If the filter does not need to manipulate the data coming from the client and if there is no need carry state b/w the filters, then we can go for this pattern.
Front Controller Pattern:
Both these patterns are almost same but this will be used when the state need to be carried to the target like after manipulating the data received from the client request or when we need to send some additional data to the destination url once request is received from the client.
Please help me in understanding these two patterns like when to use which if i'm wrong.
I think you are wrong. These two patterns are not almost the same. There are quite big differences between them, and not necessaryly those listed by you :
- Intercepting Filter allows defining loosely coupled handlers, which could be included during deployment process without changing the code (web.xml) . Also the order of filters execution could be changed in deployment descriptor. Front Controler is missing such features.
- Intercepting filter is mainly used for modifying request and response. The role of Front Controler is rather determining processing based on the request, without changing it.
My statements above could not be precise enough, I could advise you checking any of the book :
Core J2EE patterns: Deepak Alur, John Crupi, Dan Malks or Mikalai Zaikin notes or JEE study guide Cade/Roberts
Each of them contains clear definitions of each of these two patterns, emphasising the differences between them.
If you want to beter understand these patterns, I could also advise you source code analysis. "Core J2EE patterns" contains such examples. IMO it is the best way to understand the patterns. You can even create simple testservlet with some filters to make your own experiments. Its is definitely better way for learning, than reading boring lists of features of each pattern. Of course such lists are good, but only on the later stage of your preparations, when you understand the basic concepts.