users@jersey.java.net

Re: [Jersey] browser accept header weirdness

From: <FSauer_at_dsthealthsolutions.com>
Date: Wed, 7 Oct 2009 15:52:35 -0500

https://jersey.dev.java.net/issues/show_bug.cgi?id=382

Thanks Paul, also for the other reply. I'll try the ContainerRequestFilter




Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Sent by: Paul.Sandoz_at_Sun.COM
10/07/2009 03:28 PM
Please respond to
users_at_jersey.dev.java.net


To
users_at_jersey.dev.java.net
cc

Subject
Re: [Jersey] browser accept header weirdness






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.



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