2015-08-13 23:54:40 +02:00
---
layout: pattern
title: Intercepting Filter
folder: intercepting-filter
2015-08-15 18:03:05 +02:00
permalink: /patterns/intercepting-filter/
2015-08-20 21:40:07 +02:00
categories: Behavioral
2021-05-19 10:49:05 -06:00
language: en
2015-12-28 15:52:44 +02:00
tags:
2019-12-13 21:09:28 +02:00
- Decoupling
2015-08-13 23:54:40 +02:00
---
2016-01-03 21:14:30 +01:00
## Intent
Provide pluggable filters to conduct necessary pre-processing and
2015-08-13 23:54:40 +02:00
post-processing to requests from a client to a target
2018-11-04 23:42:04 +05:30
2019-12-07 20:01:13 +02:00
## Class diagram

2018-11-04 23:42:04 +05:30
2016-01-03 21:14:30 +01:00
## Applicability
Use the Intercepting Filter pattern when
2015-08-13 23:54:40 +02:00
* a system uses pre-processing or post-processing requests
* a system should do the authentication/ authorization/ logging or tracking of request and then pass the requests to corresponding handlers
2015-08-15 18:03:05 +02:00
* you want a modular approach to configuring pre-processing and post-processing schemes
2015-09-03 18:17:07 +05:30
2018-11-04 23:42:04 +05:30
## Tutorials
2019-12-13 21:09:28 +02:00
2018-11-04 23:42:04 +05:30
* [Introduction to Intercepting Filter Pattern in Java ](https://www.baeldung.com/intercepting-filter-pattern-in-java )
2016-01-03 21:14:30 +01:00
## Real world examples
2015-09-24 12:23:02 +05:30
2016-07-17 21:24:12 +02:00
* [javax.servlet.FilterChain ](https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/FilterChain.html ) and [javax.servlet.Filter ](https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/Filter.html )
2019-09-07 23:48:13 +05:30
* [Struts 2 - Interceptors ](https://struts.apache.org/core-developers/interceptors.html )
2015-09-24 12:23:02 +05:30
2016-01-03 21:14:30 +01:00
## Credits
2015-09-03 18:17:07 +05:30
* [TutorialsPoint - Intercepting Filter ](http://www.tutorialspoint.com/design_pattern/intercepting_filter_pattern.htm )