Why Servlet Filter Is Used

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. … Formatting of request body or header before sending it to servlet.

Why do we use servlet filter?

It is mainly used to perform filtering tasks such as conversion, logging, compression, encryption and decryption, input validation etc. The servlet filter is pluggable, i.e. its entry is defined in the web. xml file, if we remove the entry of filter from the web.

What is a servlet filter?

A Servlet filter is an object that can intercept HTTP requests targeted at your web application. A servlet filter can intercept requests both for servlets, JSP’s, HTML files or other static content, as illustrated in the diagram below: A Servlet Filter in a Java Web Application.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest