top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why do we have servlet filters in java?

0 votes
326 views
Why do we have servlet filters in java?
posted Sep 19, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Servlet Filters are pluggable java components that we can use to intercept and process requests before they are sent to servlets and response after servlet code is finished and before container sends the response back to the client.

Some common tasks that we can do with filters are:
Logging request parameters to log files.
Authentication and autherization of request for resources.
Formatting of request body or header before sending it to servlet.
Compressing the response data sent to the client.
Alter response by adding some cookies, header information etc.

answer Sep 20, 2017 by Pankaj Singh
...