File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing Headers to response

 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • 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: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • 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
  • 0
  • 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