Spring Boot Web Filter

Farzin Pashaee
3 min readMay 7, 2022

A Filter in the Spring Boot application is a solution used to intercept the HTTP requests and responses of your application. Filter helps us to perform two operations Before sending the request to the Dispatcher and Before sending a response to the client.

Filters are also like pointcuts in Aspect-Oriented Programming. They are easy to implement and simple to plug in and out from HTTP request processing. Filters can be used for different well-known use cases like Logging, Authentication and Security, Transaction and request manipulation, and…

Filter Interface

In order to implement your custom filter in your application, you need to implement the Filter interface. This interface has 3 methods that needed to be implemented and they will be called in different stages of the filter’s lifecycle.

init

This method will be run when the filter is created and it provides an instance of FilterConfig.

@Override
public void init(FilterConfig filterconfig)
throws ServletException {}

doFilter

--

--

Farzin Pashaee
Farzin Pashaee

Written by Farzin Pashaee

Software Engineer at Maybank, AI and ML enthusiastic

Responses (1)