| Author |
setting/not setting content-type header
|
Erin Li
Greenhorn
Joined: Mar 07, 2010
Posts: 5
|
|
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
Joined: Jan 10, 2002
Posts: 56179
|
|
|
There is no explicit default -- if you don't set one, there won't be one.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Erin Li
Greenhorn
Joined: Mar 07, 2010
Posts: 5
|
|
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
Joined: Apr 01, 2009
Posts: 639
|
|
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
Joined: Jan 10, 2002
Posts: 56179
|
|
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
Joined: Mar 07, 2010
Posts: 5
|
|
|
Thanks Bear/Mark it really helps.
|
 |
 |
|
|
subject: setting/not setting content-type header
|
|
|