Filters help you to intercept the incoming request and response.
Request filters can:
perform security checks,
reformat request headers or bodies,
audit or log requests,
Response filters can:
compress the response stream,
append or alter the response stream,
create a different response altogether.
solved What are the real time usage of Filter concept in Java Servlet? [duplicate]