本地tomcat5.5没有此问题。一切正常
代码如下:
<%
byte[] bytes=......//文件流
String file_type = (String)file.getString("fileType");
response.setContentType(file_type);
//System.out.println("---" + file_type + "---" + bytes.length);
response.setHeader("Content-Disposition", "attachment;filename=\"" + new String(file.getString("fileName").getBytes("gb2312"), "ISO8859-1" ) + "\""); response.setHeader("Pragma", "No-cache"); java.io.OutputStream output = response.getOutputStream();
try{ output.write(bytes);
output.flush();
response.flushBuffer();
out.clear();
out = pageContext.pushBody();
}catch(java.io.IOException e){
System.out.println("Error!");
e.printStackTrace();
} finally {
if (output != null) {
output.close();
output = null;
}
}
%>报错如下:
java.io.IOException: response already committed
at weblogic.servlet.jsp.JspWriterImpl.clear(JspWriterImpl.java:56)
at jsp_servlet._mpcommon.__show_file._jspService(__show_file.java:111)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
代码如下:
<%
byte[] bytes=......//文件流
String file_type = (String)file.getString("fileType");
response.setContentType(file_type);
//System.out.println("---" + file_type + "---" + bytes.length);
response.setHeader("Content-Disposition", "attachment;filename=\"" + new String(file.getString("fileName").getBytes("gb2312"), "ISO8859-1" ) + "\""); response.setHeader("Pragma", "No-cache"); java.io.OutputStream output = response.getOutputStream();
try{ output.write(bytes);
output.flush();
response.flushBuffer();
out.clear();
out = pageContext.pushBody();
}catch(java.io.IOException e){
System.out.println("Error!");
e.printStackTrace();
} finally {
if (output != null) {
output.close();
output = null;
}
}
%>报错如下:
java.io.IOException: response already committed
at weblogic.servlet.jsp.JspWriterImpl.clear(JspWriterImpl.java:56)
at jsp_servlet._mpcommon.__show_file._jspService(__show_file.java:111)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
解决方案 »
- ssh整合问题
- 关于项目报价的问题。咨询。
- JSP 上传图片出现问题,求助
- 谁有 精通J2EE:Eclipse、Struts、Hibernate、Spring整合应用案例 里面的源代码,发下好不
- 請問out.println里怎么輸出<bean:message />啊?
- file.getName()的编码是怎么样确定的
- Eclipse如何与tomcat配合使用?(最好说的详细点)
- 厦门软件龙头企业一夜失色 --- (近百名员工合法权益何处申讨)
- 为什么我的第一个J2EE程序会失败(例子来源于Sun公司的tutorial)???sos
- 界面更新信息时报了个数组越界,但是又没指定出错的代码,而且界面显示也正常,好像没影响代码的执行。有人可以给点意见吗
- 求问,JPQL如何查询一周以内的数据(MYSQL)数据库
- Hibernate和触发器Trigger协同工作中怎样在保存后自动更新pojo数据为数据库处理后的数据
output.flush();
response.flushBuffer();
out.clear();
out = pageContext.pushBody();
===> output.write(bytes);
output.flush();
out = pageContext.pushBody(); response.flushBuffer(); out.clear();
response.setHeader("Content-Disposition", "attachment;filename=\"" + new String(file.getString("fileName").getBytes("gb2312"), "ISO8859-1" ) + "\""); 中的 new String(file.getString("fileName").getBytes("gb2312"), "ISO8859-1" ), 把new String(.getBytes("gb2312"),"ISO8859-1")去掉就行了。
用tomcat是正常的。