dev@jersey.java.net

Re: [Jersey] HttpContext does not return the MediaType

From: exxos <hatufr_at_gmail.com>
Date: Tue, 7 Sep 2010 13:30:56 +0200

Hi,

Ok, but I though that the MediaType is set in the response by the
annotation @Produces? Is not the case?

Regards,
exxos.

httpContext.getRequest().getMediaType()

On Tue, Sep 7, 2010 at 1:17 PM, Pavel Bucek <Pavel.Bucek_at_sun.com> wrote:

> you should use HttpContext.getRequest(); response doesn't exists when you
> are asking for it.
>
>
> On 9/7/10 1:03 PM, exxos wrote:
>
>> Hello,
>>
>> Here is the code I'm testing:
>>
>> @Path("hello")
>> public class App {
>>
>> @Context HttpContext httpContext;
>>
>> @GET
>> @Produces(MediaType.TEXT_HTML)
>> public Response getHtml() {
>>
>> System.out.println("RESOURCE hello >>> HttpContext Response:" +
>> httpContext.getResponse());
>> System.out.println("RESOURCE hello >>> MediaType :" +
>> httpContext.getResponse().getMediaType());
>>
>> return Response.ok("Hello I'm fine !").build();
>> }
>> }
>>
>> The issue is that MediaType is "null". Could you please advise why I
>> cannot get the MediaType from the HttpContext?
>> (This is the same behavior with ExecptionMapper where I base content
>> negotiation on that)
>>
>> Best regards,
>> exxos.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>
>