users@jersey.java.net

Re: [Jersey] browser accept header weirdness

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 07 Oct 2009 22:27:58 +0200

Hi,

You have found a bug with implicit produces and the accept header when
an acceptable media type is not explicitly present in the list of
acceptable media types send by the client. Could you log an issue?

A workaround is to create a ContainerRequestFilter to modify the
accept header when the user agent is recognized as IE.

Paul.

On Oct 7, 2009, at 8:45 PM, FSauer_at_dsthealthsolutions.com wrote:

>
> The bookstore example as it comes out of the box in 1.0.3 and
> 1.1.2ea exposes a strange browser discrepancy:
>
> I added a debug statement in the Bookstore.getItem method to print
> the Accept header as follows (and this one line is the only change
> to the example code):
>
> @Path("items/{itemid}/")
> public Item getItem(@PathParam("itemid") String itemid, @Context
> HttpServletRequest req) {
> System.err.println(req.getHeader("Accept"));
> Item i = getItems().get(itemid);
> if (i == null)
> throw new NotFoundException("Item, " + itemid + ", is
> not found");
>
> return i;
> }
>
> This shows the following results when accessing http://localhost:8080/bookstore/items/1
> :
>
> Browser Accept
> header result
> ====================================================================
> Firefox text/html,
> application/xhtml+xml,
> application/xml;q=0.9,
> */
> *;q=0.8 HTML
> Safari application/xml,
> application/xhtml+xml,
> text/html;q=0.9,
> text/plain;q=0.8,
> image/png,
> */
> *;q=0.5 HTML
> IE */
> * XML(!)
>
> Is there a known problem with jersey's handling of */* when using
> implicit views?
> In both versions of the example the resources are annotated with
> @ImplicitProduces("text/html;qs=5")
>
> Any ideas?
> <mime-attachment.gif> Frank Sauer
> Principal Architect
> DST Health Solutions
> 2500 Corporate Drive
> Birmingham, AL 35242
> (205)437-5204 (Office) (Direct)
> (205)568-4684 (Cell)
> fsauer_at_dsthealthsolutions.com
> It is impossible to sharpen a pencil with a blunt axe. It is equally
> vain to try to do it with ten blunt axes instead -- Edsger W. Dijkstra
>
>
>
> Please consider the environment before printing this email and any
> attachments.
>
> This e-mail and any attachments are intended only for the individual
> or company to which it is addressed and may contain information
> which is privileged, confidential and prohibited from disclosure or
> unauthorized use under applicable law. If you are not the intended
> recipient of this e-mail, you are hereby notified that any use,
> dissemination, or copying of this e-mail or the information
> contained in this e-mail is strictly prohibited by the sender. If
> you have received this transmission in error, please return the
> material received to the sender and delete all copies from your
> system.
>