5

I get this exception when I try to send data to the client browser. I use the apache POI lib to generate a Excel file like in this example:

workbook = generateData();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=" + this.filename);
out = response.getOutputStream();
workbook.write(out);

This works well for small amounts of data, but everytime I try this with a larger amount of data it won´t work. The application needs more than 30sec to generate the data, is this too long and can I prevent this?

ClientAbortException:  java.net.SocketException: Broken pipe
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:369)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:448)
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:318)
    at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:274)
    ...
Caused by: java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:539)
    at org.apache.jk.common.JkInputStream.doWrite(JkInputStream.java:162)
    at org.apache.coyote.Response.doWrite(Response.java:560)
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:364)
user1300376
  • 85
  • 1
  • 2
  • 6
  • have you looked at this : http://stackoverflow.com/questions/2309561/how-to-fix-java-net-socketexception-broken-pipe – Oliver Watkins May 07 '13 at 11:17
  • http://stackoverflow.com/questions/12206754/broken-pipe-when-writing-bytes-in-servletoutputstream – akshayb May 07 '13 at 11:17
  • I have done this before with php and there was no problem with long running downloads. Is there any way to tell the client not to close the connection until all data is send? – user1300376 May 07 '13 at 13:41

0 Answers0