Intercepting Filter Pattern

An Intercepting Filter Pattern says that "if you want to intercept and manipulate a request and response before and after the request is processed".


Usage:

  • When you want centralization, common processing across requests, such as logging information about each request, compressing an outgoing response or checking the data encoding scheme of each request.
  • When you want pre and post processing the components which are loosely coupled with core request-handling services to facilitate which are not suitable for addition and removal.

Benefits:

  • It provides central control with loosely coupled handlers.
  • It improves reusability.

UML for Intercepting Filter Pattern:

Intercepting Filter Pattern

Implementation of Intercepting Filter Pattern:

Step 1

Create a Login.html web page.

Step 2

Create a LoginServlet class.

Step 3

Create a LoginSuccess.jsp page.

Step 4

Create an AdminPage.jsp page.

Step 5

Create an LogoutServlet class.

Step 6

Create an AuthenticationFilter class.

Step 7

Create an RequestLoggingFilter class.

Step 8

Create a web.xml file.

Output:

Intercepting Filter Pattern
Intercepting Filter Pattern
Intercepting Filter Pattern
Intercepting Filter Pattern




Latest Courses