Spring Framework — Filter vs Dispatcher Servlet vs Interceptor vs Controller
Hello everyone. In this article, we are going to look at Filter, Dispatcher Servlet, Interceptor, and Controller in the Spring framework. Understanding these components is a bit difficult initially for most Java developers as they sound similar. Each of these components has a specific purpose and knowing them well allows a developer to use them correctly. I have simplified the concepts with diagrams and examples.
Before reading this, please go through my article about Servlets to have a deep understanding of Servlets and its terminologies
What is a Filter?
As seen in the diagram above, Filters are part of the Servlet Container of the web server. It does not belong to any framework like Struts or Spring. Filters are used to manipulate the requests and the requests can even be blocked before it reaches the Servlet. It can also…