A filter is an object that intercepts a request and processes the ServletRequest or the ServletResponse passed to the resource being requested. Filters can be used for logging, encryption and decryption, session checking, image transformation, and so on. Filters can be configured to intercept a resource or multiple resources.Filter configuration can be done through annotations or the deployment descriptor. If multiple filters are applied to the same resource or the same set of resources, the invocation order is sometimes important and in this case you need the deployment descriptor.
This chapter explains how to write and register filters. Several examples are also given.
The Filter API
The following section explains ...