DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10690>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10690

ServletOutputStream blocks thread when cancelling download in IE

           Summary: ServletOutputStream blocks thread when cancelling
                    download in IE
           Product: Tomcat 4
           Version: 4.1.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Unknown
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The ServletOutputStream blocks on write (actually on its internal flush) in a
special case: when download with IE from a jsp and cancelling during save.
The ServletOutputStream blocks, and so does the thread serving it. In the
single-thread servlet model, this also locks the servlet.

---
Related problems have been posted at the user and dev mailing lists, see:

http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg19692.html
http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg16648.html

---
details of configuration:

server: standalone Apache Tomcat 4.1-dev for JavaTM Web Services Developer Pack
1.0 EA2
jsp:

<%@ page import="java.io.*" %>
<%

// let the filename point to a large text file
String filename = "D:\\log.csv";

System.out.println( "Before download" );

try {
  FileReader file_reader = new FileReader( filename );
  BufferedReader reader = new BufferedReader( file_reader );
  File log_file = new File( filename );
  long length = log_file.length();
  log_file = null;

  response.setContentType ("application/excell");
  response.setHeader ("Content-Disposition", "attachment; filename=\"" +
filename + "\"");

  response.setContentLength( (int)length );
        
  ServletOutputStream outs = response.getOutputStream();
                
  String line = reader.readLine();
  // debug code to print something for every line that is being pushed.
  int l = 1;
  while ( line != null ) {
    outs.println( line );
    System.out.println("line" + l++ );
    line = reader.readLine();
  }
  reader.close();
  file_reader.close();
  outs.flush();
  outs.close();
}
catch ( Exception e ) {
  e.printStackTrace();
}

System.out.println( "After download. If you see this, the thread has been freed." );

%>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to