This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Content Length not being sent to client in HTTP headers

 
wayne forrest
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having some trouble with the servlet API (Tomcat 6).

Setting the content length using the out.setContentLength(len) is not working, the headers is not sent
to the client when I monitor the traffic via WireShark, and yet out.println("Content-Length: "+len) works.

Is there an explanation for this?


 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely explanation is that your application has already flushed the headers to the response stream. You need to set all headers before the first write to the response stream just to be safe.

See the javax.servlet.ServletResponse JavaDocs where it is explained that setContentLength has no effect if the headers have already been sent and does not report any error.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic