I want to know basically what a Jersey filter is and how is it related to a servlet filter? Are they the same? What are the main patterns of using a Jersey Filter?
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.