[Logo]
Forums Register Login
How to get Session context in RESTFul services
Hi

I'm developing java RESTFul services using netbeans . I want to access the HTTP Session attributes in my RESTFul services.

Im not able to access any servlet features in REST Services. Is there any bridge to access the servlet api from REST.

please help me ..

raghu
Are you using jax-ws and implementing Provider<Source>?
If yes then you should have a

in your web service. webServiceContext will be initialized by the container. In your code do:
Hi!
If you are using a JAX-RS compliant web service stack, then you can annotate a parameter of the type HttpServletRequest with the @Context annotation.
Retrieving the HTTP session is trivial.
From the JAX-RS 1.1 Specification, section 6.1:
The @Context annotation can be used to indicate a dependency on a Servlet-defined resource. A Servlet- based implementation MUST support injection of the following Servlet-defined types: ServletConfig, ServletContext, HttpServletRequest and HttpServletResponse.

Best wishes!
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 17, 2017 23:57:19.