wood burning stoves 2.0
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Intercepting filter pattern vs Front Controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Intercepting filter pattern vs Front Controller" Watch "Intercepting filter pattern vs Front Controller" New topic

Intercepting filter pattern vs Front Controller

Nandu itha

Joined: Feb 08, 2010
Posts: 22
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.

Thanks in Advance

Pawel Piwowar

Joined: Feb 12, 2010
Posts: 21

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 test servlet 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.

I hope, I answered your question,


Pawel Piwowar

SCJP 5, SCWCD 1.4, SCBCD 5, SCEA part1
Nandu itha

Joined: Feb 08, 2010
Posts: 22
Thank you Vey much Pawel for the good explanation
prathap venkata naga yelugula
Ranch Hand

Joined: Aug 13, 2008
Posts: 251
Hi Pawel,
Very Good Informations.Thanks alot.
Eduardo Mineo
Ranch Hand

Joined: Sep 26, 2011
Posts: 63

Nandu, before spending your money, you should take a look here:

Core J2EE Patterns from Sun website.
I agree. Here's the link: http://aspose.com/file-tools
subject: Intercepting filter pattern vs Front Controller
It's not a secret anymore!