Count no of bytes successfully received by client

Hi All,

I am usingServletOutputStream to send binary data to client.

My code is,

--

ServletOutputStream svrResposeStrm = response.getOutputStream();

File sourceFile = new File("c:/aa.jpg);

byte [] fileBytes= getBytesFromFile(sourceFile);

svrResposeStrm.write(fileBytes);

--

In the above code function getBytesFromFile read a file and store data in byte array.

Is is possible tocount number of bytes successfully received by client? This situation may occur when client starts downloading but due to network issue or user has cancelled downloading, file is not download completely.

My requirement is to track above situation.

I have also noticed an entry in Tomcat access log

"GET /spk/aa.zip HTTP/1.1" 200 70742

This appears when i download a file 'aa.zip' which are placed in context 'spk'. This entry shows bytes70742

transferred by this request

Thanks in advance.

Message was edited by:

abhishekpandey_y2k

[1061 byte] By [abhishekpandey_y2ka] at [2007-10-3 1:03:50]
# 1
Hi All,Any idea for my problem?
abhishekpandey_y2ka at 2007-7-14 18:00:07 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

hello,

generally the HttpServletResponse has no function for the size from output. This is because it is not sure that the html (or other) you send, send unmodified to the client! Because a filter or some other app ( module) can change the doc.

Try:

File.length();

regards Dietmar

didisofta at 2007-7-14 18:00:07 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Hello,sorry for the incomplete answer.No, it is impossible, because there is no feedback fom client, how many bytes are recieved in HTTP Protocoll.regards Dietmar
didisofta at 2007-7-14 18:00:07 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...