users@jersey.java.net

_at_Context HttpServletRequest not working as expected

From: Haresh K <hk.techmail_at_gmail.com>
Date: Tue, 19 May 2009 17:56:21 -0400

Hello,Perhaps this question has been asked before, if so, I am sorry. Kindly
point me to the right place.

I am trying to use @Context annotations for ServletContainer and it does not
seem to inject the right data.

The program:

@Path (value="/test")
@Produces ({MediaType.APPLICATION_XML})
public final class TestResource
{
    @Context HttpServletRequest servletRequest;

    @GET
    public Resource get()
    {
        System.out.println(servletRequest.getCharacterEncoding());
        System.out.println(servletRequest.getContentType());
        System.out.println(servletRequest.getContextPath());

        return null;
    }
}

produces the following response:

null
null

null

Is this a bug or am I doing something wrong?

(I am using Jersey 1.0, JDK 1.6, configured
Servlet com.sun.jersey.spi.container.servlet.ServletContainer )

thanks for your help
-hk