Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing Headers to response

 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ranchers,

What happens when "The servlet container does not write the headers before committing the response, because in HTTP the headers must be sent before the response body."

Do we end up in an IllegalStateException???
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any participants for the post above?
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jothi Shankar Kumar Sankararaj:
"The servlet container does not write the headers before committing the response, because in HTTP the headers must be sent before the response body."


Jothi,

I don't understand the statement. What I know is that if we try to write headers after the response has been commited we get an IllegalStateException. There is no way that the Container won't write the headers before (if you didn't specify any, it will write the defaults). What I think happens is that the Container will send the headers just before it sends what we wrote to the outputStream when commiting the response (e.g., flushes the buffer for the first time if there is a buffer, or if there is no buffer when the first char is sent).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic