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?
Author and all-around good cowpoke
posted 6 years ago
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.