首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

文件上载取消保存上载错误

2012-12-25 
文件下载取消保存下载异常Caused by: java.net.SocketException: Connection reset by peer: socket write

文件下载取消保存下载异常

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();  


异常现状:点击下载,不保存文件,直接点取消,IE 下取消上面异常。
解决方案:bos.flush(); 代码位置移到 byte[] buffer = new byte[1024]; 缓冲区write(...)之前

热点排行