Hi,
I am working on a performance measurement tool and need to measure how long a client needs to download data from a servlet. I was doing this from a client, but ran into curious behaviour with ServletOutputStream.
The server response is put into a ByteArrayOutputStream (outBuffer) and then written to the ServletOutputStream like this:
log("Starting");
OutputStream out = response.getOutputStream();
out.write(outBuffer.toByteArray());
out.flush();
out.close();
log("Done");
I always assumed that the response would be buffered somewhere in the servlet environment so that the servlet would not be blocked by a slow client. However the log("Done") statement is only reached when the client is finished reading. I can step through the client and the servlet will wait obediently (until some timeout is reached). The servlet is running on Tomcat 5.5.
Q1. Can i assume that when the log("Done") statement is reached the client has read all of the data in the response and has closed the connection?
Q2. Can anyone point me to some documentation on how a ServletOutputStream works exactly. The javadoc details the client side or the server side, but not what is going on while both are exchanging data.
Thanks in advance,
Robin