users@jersey.java.net

Re: Setting server preferred media type

From: Tim Williams <williamstw_at_gmail.com>
Date: Wed, 16 Jun 2010 12:27:11 -0400

Thanks Paul, that's great. Google isn't helping me find documentation
for this feature, if you could point me somewhere useful, I'm happy to
RTM btw:)

I notice that the qs value gets sent to the client along with the MIME
type, is there a way to turn that off? Or, is a 'qs' attribute
allowed for all MIME types?

Thanks,
--tim


> Hi Tim,
>
> Jersey supports what is termed "quality of source" with the "qs" media
> type parameter, for example:
>
> @GET
> @Produces("application/xml;qs=2")
> public Object getAsXml()...
>
> @GET
> @Produces("text/plain")
> public Object getAsText()...
>
> @GET
> @Produces("text/html;qs=3")
> public Object getAsHtml()...
>
>
> This means that ""text/html" will take precedence over "application/
> xml" which takes precedence over "text/plain".
>
> Further more if the accept header is say:
>
> "application/xml, text/html;q=0.8"
>
> or
>
> "application/xml, text/*;q=0.8"
>
> the "text/html" will still take precedence.
>
> Hth,
> Paul.
>
>
> On Tue, Jun 15, 2010 at 2:45 PM, Tim Williams <williamstw_at_gmail.com> wrote:
>> I'm wondering how to indicate the server preferred
>> representation/Media Type when the client's */* preference hits?
>> Suppose, I have something like:
>>
>> @GET
>> @Produces("application/xml")
>> public Object getAsXml()...
>>
>> @GET
>> @Produces("text/plain")
>> public Object getAsText()...
>>
>> @GET
>> @Produces("text/html")
>> public Object getAsHtml()...
>>
>> If a client sends Accept: */* (e.g. curl http://example.com --header
>> "Accept: */*"), Jersey chooses the application/xml representation.
>> How do I indicate that the server default should be text/html? It
>> seems to prefer application/xml in all cases I could find.
>>
>> Thanks,
>> --tim
>>