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:49:39 GMT
my problem is that I can't distinguish a valid request from a cancelled one.
Tomcat in some instances stops my servlet exeution and in others lets it go
as if I didn't cancel.
There doesn't seem to be a time difference between downloading 50MB and the
time it would have taken to complete the download had I not clicked
'cancel'.

I would have expected the socket to be closed and an IO exception to be
thrown in my servlet - but if the servlet just stops as it sometimes does,
that's ok too.

Charlie

> -----Original Message-----
> From: Barry White [mailto:barrywhite@charter.net]
> Sent: Wednesday, October 17, 2001 5: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