I'm planning on writing a servlet application (meant for deployment with OSGI) and use some filters for HTTP header pre-processing. While originally settled on the javax.servlet filter implementation, it occured to me that I actually don't know why/when one would choose to use that vs the Jersey ContainerRequestFilter. Granted the latter comes with some pre-built filters, but arguably so does the former (eg Cors filter). Thus, what should be considered when choosing which API to use? Are there specific cases when one should not be used in favor of the other?
Whatever you decide, you will be using a javax.servlet based Filter implementation, since it is the base interface for every Filter
you use in Java EE.
http://docs.oracle.com/javaee/6/api/javax/servlet/Filter.html
Now, Jersey comes with an implementation that adds some functionality (access to your ContainerRequestContext
or whatever you would need inside your Jersey application). Are you using Jersey already in your application? Then go for it, if not I would not bother (at least a priori and without further information) and just go for the most simple possible implementation of javax.servlet.Filter
and put it straight into my web.xml