tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cox, Charlie" <c...@cincom.com>
Subject RE: cancelled request
Date Thu, 18 Oct 2001 14:45:57 GMT
thanks, but flush() doesn't help. 

I guess I need to know if there is a way to detect that the request has been
cancelled?

Charlie

> -----Original Message-----
> From: Rajah Kalipatnapu [mailto:rajah@soundpipe.com]
> Sent: Wednesday, October 17, 2001 6:15 PM
> To: tomcat-user@jakarta.apache.org
> Subject: RE: cancelled request
> 
> 
> I'm not sure how far this helps. But try flush() every time 
> you write bytes
> to outputstream.
> Even though u r loosing the advantage of BufferStream by 
> flushing every
> time, there is a chance that u'll get an IOException if the 
> user cancels the
> download and the IOStream is closed, as the flush() forces 
> the bytes to the
> end stream.
> 
>  while(-1 != (bytesRead = bisDownload.read(buff, 0, buff.length)))
>  {
>    bosDownload.write(buff, 0, bytesRead);
>    bosDownload.flush();
>  }
> 
> -Raj
> 
> -----Original Message-----
> From: Barry White [mailto:barrywhite@charter.net]
> Sent: Wednesday, October 17, 2001 2:50 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: cancelled request
> 
> 
> I have never done anything like that but I was thinking you 
> could use some
> kind of timeout in your servlet.  Try doing this in your 
> while loop.  You
> could also check bytesread and make sure it is changing.
> 
> hope this helps,
> Barry
> ----- Original Message -----
> From: "Cox, Charlie" <ccox@cincom.com>
> To: <tomcat-user@jakarta.apache.org>
> Sent: Wednesday, October 17, 2001 4:32 PM
> Subject: cancelled request
> 
> 
> > 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
> > BufferedOutputStream(resp.getOutputStream());
> > byte[] buff = new byte[2048];
> > int bytesRead;
> >
> > while(-1 != (bytesRead = bisDownload.read(buff, 0, buff.length)))
> > {
> > bosDownload.write(buff, 0, bytesRead);
> > }
> > bosDownload.close();
> > bisDownload.close();
> >
> >
> > 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.
> >
> > Charlie
> >
> 

Mime
View raw message