users@jersey.java.net

Content negotiation woes

From: Daniel Larsson <daniel.j.larsson_at_gmail.com>
Date: Thu, 10 Jun 2010 18:13:05 +0200

Hi all,

How do people generally handle content negotiation? In theory, this is
wonderfully handled with the Accept header, and Jersey's @Produces
annotation, but in practice, several popular browsers send non-sensical
Accept header values, making content negotiation a pain.

Jersey provides a way to fake Accept header values through URL extensions.
The drawback with this approach is you have to be careful with resource
naming (e.g. if you expose users as resources, and someone decides to name
themselves "foo.xml").

Write a servlet filter to rewrite the Accept header for known bad user
agents? *sigh*

Give up on content negotiation, and provide separate resources for different
representations? :-/