0

I am studying Filter in REST web-services and I have some confusion in postMatching and preMatching server Request filter , can any one clearly explain it ? when to use ?

PRIYANK SINHA
  • 111
  • 1
  • 10
  • Did you try to do something specific? Provide the code. Please create a [create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – radu-matei Sep 05 '15 at 20:23

1 Answers1

3

I think this excerpt from the Jersey documentation explains the difference really well:

post-matching filters [...] would be applied only after a suitable resource method has been selected to process the actual request i.e. after request matching happens. Request matching is the process of finding a resource method that should be executed based on the request path and other request parameters. Since post-matching request filters are invoked when a particular resource method has already been selected, such filters can not influence the resource method matching process.

To overcome the above described limitation, there is a possibility to mark a server request filter as a pre-matching filter, i.e. to annotate the filter class with the @PreMatching annotation. Pre-matching filters are request filters that are executed before the request matching is started. Thanks to this, pre-matching request filters have the possibility to influence which method will be matched.

Gergely Bacso
  • 14,243
  • 2
  • 44
  • 64