users@jersey.java.net

[Jersey] Re: Response entity and Accept mediatype?

From: Mike Summers <msummers57_at_gmail.com>
Date: Thu, 26 Jul 2012 18:28:23 -0500

Thanks Jakub, it looks like this will get me pointed in the right direction.

--Mike

On Thu, Jul 26, 2012 at 12:14 PM, Jakub Podlesak
<jakub.podlesak_at_oracle.com>wrote:

> Hi Mike,
>
> One way of solving this would be to utilize the standard
> Request.selectVariant method (see [1]).
> You should be able to inject the request instance to your resource method
> and pass it your
> custom, say variants, Variant list. If the above method returns null, you
> hit the case
> where the most suitable response would be just: Response.notAcceptable(**
> variants).build();
>
> HTH,
>
> ~Jakub
>
>
> [1]http://jsr311.java.net/**nonav/javadoc/javax/ws/rs/**core/Request.html#
> **selectVariant(java.util.List)<http://jsr311.java.net/nonav/javadoc/javax/ws/rs/core/Request.html#selectVariant(java.util.List)>
>
>
> On 7/23/12 9:43 PM, Mike Summers wrote:
>
>> What's a good way to return Response entities that don't cause a marshal
>> error on the entity when there's no @Provider that matches the Accept
>> header media type?
>>
>> I don't think I'll be able to get the client to change their Accept to
>> something like "Accept: <preferred-type>,application/**xml;q=0.9" which
>> would solve my problem.
>>
>> Is there anything smart I can do server side? This only happens in error
>> cases, and we have an ExceptionMapper, maybe there's something we can do
>> there?
>>
>> Thanks.
>>
>
>