• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting/not setting content-type header

 
Erin Li
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I read here that content-type's default for servlets is text/plain.
Is that correct? I'm using firebug to see the response header. I didn't set any content-type in my servlet. I got this response header in firebug:

Response Headers
Server Apache-Coyote/1.1
Content-Length 27
Date Sun, 07 Mar 2010 17:13:04 GMT


Thanks
Erin
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no explicit default -- if you don't set one, there won't be one.
 
Erin Li
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear for the reply.
One additional question! what would be the side effects on the browser for not setting any content-type?

Regards
Erin
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Erin Li wrote:Thanks Bear for the reply.
One additional question! what would be the side effects on the browser for not setting any content-type?

Regards
Erin

Then the browser has to guess what to do with the content. Will all browsers guess correctly?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64832
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Browsers maintain a map of how to deal with MIME types of the content sent to them. If they need to guess, they'll probably use a number of techniques to determine the MIME type, the most visible of which will be examining the URL for file types. It's a safe bet that all browsers will deal with content whose URL.s end with .html or .txt correctly.

In a servlet environment where URLs are mappings rather than references to physical files with file types, most browsers will simply assume a universal default of text/html.
 
Erin Li
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear/Mark it really helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic