简体   繁体   中英

Storing session objects in Jax-Rs Jersey

I am currently writing a web application using jersey-mvc and jersey-mvc-freemarker .

It is working fine , but I need a way to store session data.

On Servlets, I would use the HttpSession object, but I am wondering if there is a more JAX-RS-ish way to do it. Can someone please help?

In Jersey you can add HTTP Request to your context using injection:

@Context
private HttpServletRequest httpRequest;

and then in method get HTTPSession object by:

httpRequest.getSession()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM