Servlet Filter and Spring Interceptors are important concepts in java world. But there is always confusion between both concepts. Both serve almost the same concept but there are differences when to use and for which purpose.
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.
For authentication of web pages, you would use a servlet filter.
Security stuff in your business layer or logging/bug tracking (a.k.a.
independent of the web layer) you would use an Interceptor.
For the Login authentication and auditing of incoming requests from web pages, we should use a servlet filter.
While for implementing your business layer logging and auditing and many other along feature we should use an Interceptor.
Filters implement javax.servlet.Filter
Interceptors implement org.springframework.web.servlet.HandlerInterceptor