How to access HttpServletRequest in JAX RS Resource

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to access HttpServletRequest in JAX RS Resource

This post has NOT been accepted by the mailing list yet.
I tried to access HttpServletRequest in a Jax RS Resource as follows:
public class PositionResource {

    @Consumes( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
    @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
        public PositionResponse position(@Context HttpServletRequest httpServletRequest, PositionRequest positionRequest) {
                String remoteAddress = httpServletRequest.getRemoteAddr();
                Locale locale = httpServletRequest.getLocale();
                return positionResponse;

I get Http Status 404.

If I remove @Context HttpServletRequest httpServletRequest from the method signature then it works fine.
Could you please let me know how to access HttpServletRequest in JAX RS Resource.

Restlet Version: 2.1.7
Web Container: JBoss 5.0