Question - Why do we need Servlet Filter?
Answer -
We need Servlet Filters for the following reasons:
- Logging the request parameters to log files.
- Authentication and Authorization of the request for the needed resources.
- Formatting of the request body/header before sending it to the servlet.
- Compressing response data sent to the client.
- Change the response by adding some cookies and header information.