Re: Interceptors vs Filters

Rahul <[email protected]> Wed, 28 May 2014 18:59:42 +0000 (UTC)
Newsgroups gmane.comp.java.springframework.user
Message-ID <[email protected]>
 <Sebas.Panikulam <at> wellsfargo.com> writes:

> 
> 
> 
> 
> I have a question about Spring interceptors:
> 
> What is the difference between Spring Handler Interceptors and Servlet 
Filters? It looks like they are similar, but which one is better? 
> 
> I think HandlerInterceptor has some additional methods like preHandle, 
postHandle, afterCompletion which makes more powerful. Is there any other 
advantage?  Can somebody give a best example where I can go for Interceptor.
> 
> I am looking for a way through the Framework where I can redirect the user 
to the Login Page on an activity after session timeout. I was initially 
thinking I would do with Filter, but thought I can do better with 
Interceptor (something like extending HandlerInterceptorAdapter). Can 
somebody give a comment on this.
> 
> Thanks in advance
> 
> Sebas 
> 
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> 
> _______________________________________________
> Springframework-user mailing list
> Springframework-user <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/springframework-user
> 


A Servlet Filter is used in the web layer only, you can't use it outside of 
a web context. Interceptors can be used anywhere. That's the main 
difference.

http://www.javabench.in/2011/10/java-difference-between-filter-and.html


------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Springframework-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/springframework-user