Wednesday, November 28, 2012

Interceptors Vs Filters???

1) The most significant difference is that "interceptors" are a part of the Struts 2 framework, and are only part of requests handling that is done by the Struts 2 framework.
 "Filters" on the other hand are a part of the Servlet Specification in other words, they are part of the Servlet API. If you are using Struts 2, you should user interceptors for wrapping functionality around your Struts 2 actions. If you are trying to wrap functionality around requests coming to your web application, but not being handled by Struts 2, then a filter might be more appropriate.

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.

Filters are an implementation of the Intercepting Filter pattern while Interceptors are of the Interceptor pattern.

Thanks,

1 comment:

  1. I believe interceptors are in other frameworks like spring also.

    ReplyDelete