tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cox, Charlie" <>
Subject cancelled request
Date Wed, 17 Oct 2001 20:32:45 GMT
I didn't see anything about this in the archives, so hopefully someone can
help me out here.

TC 3.2.1/IIS 5/W2K
I am using a servlet to serve a large file (50MB) and everything works fine
if it completes as requested. But if the user clicks 'cancel', I get
different results from Tomcat. Sometimes the servlet stops running where it
is, as if the thread is interrupted, while other times it continues running
like nothing happened. In the both cases the download box disappears from
the browser. Netscape 6.1,4.7 and IE 5.5 all act the same way. (IE 5.0 has a
problem here, but I have other problems with it too).

here's the code in my servlet providing the file

resp.setContentType("application/octet-stream; name=somefile.exe;");
resp.setHeader("Content-Disposition", "attachment;filename=somefile.exe;");
resp.setHeader("Content-Length", String.valueOf(filelength) + ";");	

InputStream isDownload;
isDownload = getServletContext().getResourceAsStream(filename);
BufferedInputStream bisDownload = new BufferedInputStream(isDownload,2048);
BufferedOutputStream bosDownload = new
byte[] buff = new byte[2048];
int bytesRead;

while(-1 != (bytesRead =, 0, buff.length)))
	bosDownload.write(buff, 0, bytesRead);

The reason that this is an issue is that I send an email upon completion of
this download, and it shouldn't be sent if the user clicks 'cancel' but it
is being sent when the servlet continues processing. I've also wrapped this
code is a try/catch and no exception/error is ever thrown.


View raw message