Bug 7092 - socket error while trying write to response.getOutputStream() with <security-constraint> on servlet
Summary: socket error while trying write to response.getOutputStream() with <security-...
Status: RESOLVED DUPLICATE of bug 3509
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Connector:Webapp (show other bugs)
Version: 4.0 Beta 4
Hardware: PC All
: P3 major with 3 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-13 17:01 UTC by fdtdmipt
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fdtdmipt 2002-03-13 17:01:39 UTC
If servlet is secure and trys to do:

if (fromFile.exists() && !fromFile.isDirectory()) {
      	    byte[] buf = new byte[100*1024];
      	    //Set header and mime type
      	    String mimetype = downloadConfig.getServletContext().getMimeType( 
fileName );
      	    response.setContentType( (mimetype != null) ? 
mimetype : "application/octet-stream" );
            response.setContentLength( (int)fromFile.length() );
            response.setHeader( "Content-Disposition", "attachment; 
filename=\"" + request.getParameter("file") + "\"" );
      	    BufferedInputStream bufIS = new BufferedInputStream(new 
FileInputStream(fromFile),1024*1024);
      	    int byteRead;
      	    ServletOutputStream out = response.getOutputStream();
      	    while( (bufIS != null) && (byteRead = bufIS.read(buf,0,100*1024)) !
= -1) {
      	      out.write(buf,0,byteRead);
      	    }
      	    bufIS.close();
      	    out.flush();      	    
      	    out.close();

than output is ok only first time. Any other attempt to do it arise the socket 
error and put in log file:

2002-03-13 17:47:02 [org.apache.catalina.connector.warp.WarpConnector] Error 
accepting requests
java.net.SocketException: socket closed
	at java.net.PlainSocketImpl.socketAccept(Native Method)
	at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:468)
	at java.net.ServerSocket.implAccept(ServerSocket.java:243)
	at java.net.ServerSocket.accept(ServerSocket.java:222)
	at org.apache.catalina.connector.warp.WarpConnector.run
(WarpConnector.java:590)
	at java.lang.Thread.run(Thread.java:484)
Comment 1 Pier Fumagalli 2002-04-29 12:44:06 UTC

*** This bug has been marked as a duplicate of 3509 ***