Filters and interceptors are registered as providers. Filters are typically used for modifying the message headers. To understand filters, let's look at a practical use case. Cross-origin requests are requests that are made from one domain to another. It's not alien to have your web resources hosted on one domain while the requests may originate from another. For security reasons, browsers restrict such requests, which are made within scripts. The solution is Cross-Origin Resource Sharing (CORS); this mechanism allows servers to publish the set of origins that are allowed for making web browser requests to it. This is done by adding the Access-Control headers to the response, and to do that we would need to define a provider which implements the ContainerResponseFilter interface:
@Provider
public class CorsRespFilter implements ContainerResponseFilter...