users@jersey.java.net

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

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 15 May 2008 09:54:39 -0400

On May 15, 2008, at 8:13 AM, Jo Størset wrote:
>
> 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?
>
If you are prepared to relax the same url constraint a little you
could use URL-based conneg such that:

someuri.html => text/html
someuri.xml => application/xml

This can be set up globally using the application configuration and
you only to implement a resource class with @Path("someuri") and have
methods that return HTML and XML.

Marc.

> 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?
>
> Jo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.