Dear all

I am a newer on this mailing list, I tried to read the
archive but I can not found the answer for my
question. My problem is :

I write some servlet for user to download file from
our web site, It works well, every request is logged
at the logfile so I can recogize who downloaded which
file . But now i found the problem. when the User
canced the Downloading process, the OutputStream
continue to write out (instead of dead) and there are
no any Exception to be thrown therefore mylogfile have
wrong messages.

For example my code look like :

public long saveFile(String name, OutputStream out)
                             throws
FileNotFoundException, IOException,SocketException   {
FileInputStream in = null;
    long count = 0;
    try {
      in = new FileInputStream(name);
      byte[] buff = new byte[1024];
      int readin;
      while ((readin = in.read(buf)) >0) {
        out.write(buf, 0, readin);
        count=count+readin;
        out.flush();
      }
    }

    finally {
      if (in != null) fis.close();
    }
    return count;

When I invoke this method in my servlet, It does not
throw any Exception when the browser cancel ( or press
Stop button) the downloading process. The "count"
variable is always equal the length of the downloading
file

Could some one give me some dirrections : How to
recognize the OutputStream was broken by Browser, so
that I can generate the right logfiles

Thank you

__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to