ok, here the concept that gets me puzzled. 1.) I read that Keep-Alives are there to avoid unnecessary re-establishments of connections on web pages that have more than one file (e.g., with graphics, etc.) 2.) In a socket connection, the browser will know that a particular file is ended by counting the Content-Length header sent by the server, so that the browser can request more files. 3.) So, my impression is that, when we produce a file using PrintWriter out = HttpServletResponse.getWriter(); out.println();... The servlet postpones the sending of the text through the connection until it knows exactly how long the response is. 4.) So, now my question is: What happens if the HTML file that we're producing is larger than the output/response buffer (usually 8K)? The servlet must send the initial 8K of data, but it still does not know how many will be sent... If it does not know the total length, then it can't set the Content-Length header... but if it does not set the Content-Length header, then it can't send the data...
Content-length is really only essential for resources like zip files, image files and pdf files where special handling is needed and you can figure out the length before sending anything. Browsers obviously can cope with HTML that just keeps on coming. A browser can start requesting images, etc. before the HTML is complete without opening a new connection. Bill
Joined: Jul 02, 2002
Thanks for clearing that one up!
subject: need some clarification about keep-alives and content-lengths