What is a Jersey Filter?

The first part of your question may be answered in the Jersey documentation. A Jersey filter is not the same as a servlet filter. There are two filters included in Jersey, a filter for logging requests and one for compression (GZip). Another use case for a custom filter would be authentication or authorization.


Technically, a Jersey filter is not a servlet filter. However, you can use a Jersey filter for many of the same things that you would use a servlet filter for - cross-cutting concerns that affect all (or some, or most) the services that Jersey exposes.

As the previous answer states, Jersey comes with two filters, but you can usefully implement the Jersey interfaces ContainerRequestFilter or/and ContainerResponseFilter if you don't want to extend them. You're not limited to these two.

Another Jersey interface to keep in mind is ResourceFilter - this interface can be implemented for a filter that affects only some of the services.