users@jersey.java.net

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

From: Jo Størset <jo.storset_at_usit.uio.no>
Date: Fri, 16 May 2008 17:22:05 +0200

Den 15. mai. 2008 kl. 15.54 skrev Marc Hadley:

> 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.

Maybe a dumb question, late friday afternoon, but what's the easiest
way to configure this?

By the way, servlet filter and a custom MessageBodyWriter worked as
expected. I think I'll use a servlet filter for now, so then I need
the option of an explicit url for the xml variant, and thought I'd try
this mechanism.

Jo