0

I have a RESTful web services application that reads from the database and returns objects in JSON format. It works flawless in Chrome and Firefox. Unfortunately, when I am testing it in Internet Explorer (IE), IE does not want to display JSON objects. It asks if I want to save it. I don't want to save it. I want to display JSON just like in Chrome and Firefox.

Could anyone please point me in the right direction on how to fix it? I read somewhere that I can tweak the properties of my IE browser in order to display JSON as plain text, but this is not an option for me. In the future the application will be used by other people, and some of them might use IE as their browser.

My code looks something like this:

@GET
@Path("/read")
@Produces("application/json") 
public Something read(@QueryParam("page") String page){
//bluh bluh bluh
}

Thank you.

slrom
  • 144
  • 1
  • 3
  • 11

2 Answers2

1

The question appears very similar to another question asked here

How can I convince IE to simply display application/json rather than offer to download it?

The second answer specified there seems to be what you want.

Community
  • 1
  • 1
Viswas Menon
  • 310
  • 3
  • 11
0

IE is not handling rightfully the content type application/json.

You could change the content type, accordingly to the user-agent but it's kind of dirty. You could also change it to text/javascript for everyone, it's a little less dirty.

ToYonos
  • 16,469
  • 2
  • 54
  • 70