文件下载取消保存下载异常
Caused by: java.net.SocketException: Connection reset by peer: socket write errorat 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.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:737)at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:299)at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:963)at org.apache.coyote.Response.action(Response.java:183)at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)... 26 more2012-12-14 9:22:13 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet action threw exceptionjava.lang.IllegalStateException: Cannot forward after response has been committedat org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:302)at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) ......................下载代码: bos = new BufferedOutputStream(fos); response.reset(); String fileName = "download.wmv" response.setHeader("Content-disposition", "attachment;filename =" + new String(fileName.getBytes("GBK"),"ISO8859-1")); int bytesRead = 0; byte[] buffer = new byte[1024]; while((bytesRead = bis.read(buffer)) != -1){ bos.write(buffer, 0, bytesRead); } bos.flush(); fis.close(); bis.close(); fos.close(); bos.close();