How can you transfer data from a filter to an endpoint in Jersey

Can you transfer some data from javax.servlet.Filter to the Jersey endpoint without using ThreadLocal or HttpSession?

And since the first question will be β€œwhy do you want to do this?”: Mostly curious. In practice, I think I can use this to transfer some data created during authentication to the endpoint. Not using ThreadLocal eliminates the temptation to use this in a chain (I hope there is no need to explain why this is evil), and not using HttpSession is rather a fad :)

+3
source share
1 answer

Try @Context . I'm not sure which object you will receive (somewhere I saw a WebServiceContext , which is jax-ws), but it should contain an HttpServletRequest . so you can set the request attributes to the filter and read them in the recreation service

+6
source

All Articles