• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Differences between filter and Interceptors?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm researching this so that I can respond better in interviews. I've been searching around for a clear and concise answer.

So far, and by all means correct me if I am wrong or lacking in detail:

1. Filters are part of the Servlet API, Interceptors are Struts 2. (Seems obvious though)
2. The Interceptor stack fires on requests in a configured package while filters only apply to their mapped URLs.
3. Interceptors can be configured to execute or not depending on specific target action methods via excludeMethods and includeMethods while Filters lack this feature.
4. Filters are an implementation of the Intercepting Filter pattern while Interceptors are of the Interceptor pattern.

Does this seem like an accurate and complete answer? Should I add anything?
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Avoid cross posting Fiters vs Interceptor.

Above 3 points are correct I'm not sure about last one. Interceptors follows command pattern I wanna add one more point even struts2.x required a filter StrutsPrepareAndExecuteFilter is act as a centralized request processing.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic