What are filters in JSP?

JSPJava 8Object Oriented ProgrammingProgramming

Servlet and JSP Filters are Java classes that can be used in Servlet and JSP Programming for the following purposes 

  • To intercept requests from a client before they access a resource at the back end.

  • To manipulate responses from the server before they are sent back to the client.

There are various types of filters suggested by the specifications −

  • Authentication Filters
  • Data compression Filters
  • Encryption Filters
  • Filters that trigger resource access events
  • Image Conversion Filters
  • Logging and Auditing Filters
  • MIME-TYPE Chain Filters
  • Tokenizing Filters
  • XSL/T Filters That Transform XML Content

Filters are deployed in the deployment descriptor file web.xml and then map to either servlet or JSP names or URL patterns in your application's deployment descriptor. The deployment descriptor file web.xml can be found in <Tomcat-installation-directory>\conf directory.

When the JSP container starts up your web application, it creates an instance of each filter that you have declared in the deployment descriptor. The filters execute in the order that they are declared in the deployment descriptor.

raja
Published on 20-Mar-2019 09:56:16
Advertisements