Do ServletOutputStreams block until client has acknowledged receipt?
posted 11 years ago
I am developing a web-server that allows a client app to download files from the server. I have this working correctly using ServletOutputStream to write the files back to the client.
When using our JavaTest Harness and various web-browsers to download the files the performance for a 1.4 meg file is around 2 seconds. However the .NET client (witten by another software company) to do the same thing takes ages to download the file.
I have tracked the performance issue down to the ServletOutputStream.write() method calls - where I am writing 8kb blocks in each time. My question is - how does the ServletOutputStream work? - if the .NET client takes ages to process a given block of bytes, will the ServletOutputStream.write() method call not return (or block), until the bytes have been acknowledged?
Once I know for sure about this, I can then confidentally raise it with the Project Manager as being an issue with the other vendor's .NET code, and not our fault.
Additionally, I am using buffered readers for input, and am writing the entire buffer (8kb) with one write to the ServletOutputStream. 8kb is also the size of the write buffer on the HttpServletResponse. The file is being read using a buffered input reader.