users@jersey.java.net

Re: [Jersey] http and xml on the same path

From: Jo Størset <jo.storset_at_usit.uio.no>
Date: Thu, 15 May 2008 14:48:25 +0200

Den 15. mai. 2008 kl. 14.13 skrev Jo Størset:

> I wan't to serve text/html by default to browsers, but also be able
> to deliver application/xml on the same url,
> is there any way to achieve this with jersey?
>
> It seems that browser clients (at least firefox/safari) prefer xml
> over html by default in the accept header, so I need some way of
> tweaking jerseys matching algorithm (?)
>
> Would it be possible to get jersey to choose @ProduceMime("text/
> html") over @ProduceMime("application/xml") if the client says it
> accepts html (even if it's less weighted than xml)?
>
> The http spec says that I SHOULD respect the weight, by I don't see
> any better ways to handle this case of wanting browsers to get html
> by default. Does anyone know of a better solution?


I should probably add that I use a template processor to generate the
html, so I can't do the conneg in my own code. I need seperate methods
for xml and html, where the former return my jaxb domain object and
the latter a Viewable.

Jo