Yes, I have found the same behaviour, and not only with IE8, but with IE7 too.

The problem seems to be that IE sends an Accept: */* HTTP header and
Restlet's content negotiation logic is providing the "default"
representation, in your case JSON (in mine XML), for the Resource.

All the other major browsers (Firefox, Safari, Opera, Chrome) send the
correct text/html media type in their Accept HTTP header, thus making
things work as expected (as usual).

As a workaround you could add browser sniffing code targetting IE on
your Restlet/Resource class(es), and if IE is detected provide it with
the HTML representation. It may prove to be lots of work, but this is
not really Restlet's fault, but IE's (why a web browser would accept
anything other than the usual expected web media types, and even more
accept ANYTHING as the sole representation of a web resource, is
really out of my understanding).

Hope this helps.

On Wed, Dec 2, 2009 at 5:52 PM, Erick Fleming <[email protected]> wrote:
> Has any found this problem.  Firefox and Chrome get directed to the HTML
> output, but IE 8 is being routed to the JSON call.
>
> class SampleResource extends ServerResource {
>
>     @Get("html")
>     def asHtml() = {
>         new StringRepresentation(<h1>Hello World</h1>.toString,
> MediaType.TEXT_HTML)
>     }
>
>     @Get("json")
>     def asJson() = {
>         new StringRepresentation("""{"message":"hello world"}""",
> MediaType.APPLICATION_JSON)
>     }
> }
>
> object RestlyServer {
>
>     def main(args:Array[String]) {
>
>         val component = new Component
>
>         component.getServers.add(Protocol.HTTP, 8080)
>         //component.getDefaultHost.attach(new blog.BlogApplication)
>         component.getDefaultHost.attachDefault(classOf[SampleResource])
>
>         component.start
>     }
> }
>
>



-- 
Fabián Mandelbaum
IS Engineer

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2426491

Reply via email to