Hi

I am streaming a huge file from a servlet to the browser.
It can easily be multiple gigabytes.

Currently the data is prepared on the server, stored in a file and then sent to 
the client with a "Content-Disposition: attachment" header, so the browser 
handles it as a download. After the transfer the file is immediately deleted.

This kind of works but has two big disadvantages:
1. The client has to wait a long time until the first byte is transferred. I am 
afraid I could run into browser (or generic client) timeouts.
2. I need a lot of storage on the server.

The data I have could easily be streamed directly to the client without storing 
it on the server at all.
I would not know the precise size of the data In advance, but it could be 
transferred using "Transfer-Encoding: junked" so this would not be a problem.

My problem is that if anything goes wrong while creating the data I have no way 
to notify the client, as the response headers were already sent way before.
So I am looking for a way to cancel the download from the server side and 
letting the client know that something went wrong.
Simply stopping sending data is not enough, the client needs to know that the 
data is incomplete. 

Probably the only way to do that would be to abruptly disconnect the http(s) 
connection without completing the download using a "0\r\n" end marker.

So my questions are:
1. How can I force tomcat to disconnect a client like that?
2. Does anyone here have tried anything like that before? What client side 
reactions did you notice?


Best regards,
  Steffen

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to