BUG:getOutputStream() has already been called for this response
2014-03-13 16:00
120 查看
问题:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
分析:
出现该问题最根本的原因是在Servlet中使用了两种输出机制
jsp默认是JspWriter流,而你可能在程序中启用了另外一个输入/输出流,比如说文件下载的时候
解决:
在操作流文件的jsp文件最后增加
out.clear();
out=pageContext.pushBody();
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.IllegalStateException: getOutputStream() has already been called for this response org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:538) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:424) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
分析:
出现该问题最根本的原因是在Servlet中使用了两种输出机制
jsp默认是JspWriter流,而你可能在程序中启用了另外一个输入/输出流,比如说文件下载的时候
首先你要知道pushBody()的作用是保存当前的out对象,并更新PageContext中Page范围内Out对象。至于为什么要加上这句话,是因为JSP容器在处理完成请求后会调用releasePageConter方法释放所有的PageContestObject,并且同时调用getWriter方法。由于getWriter方法与在JSP页面中使用流相关的getOutputStream方法冲突,所以会造成这种异常
解决:
在操作流文件的jsp文件最后增加
out.clear();
out=pageContext.pushBody();
相关文章推荐
- (生成excel)解决getOutputStream() has already been called for this response java getOutputStream()的问题
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- SSH中发生异常java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- 遇到问题----java.lang.IllegalStateException: getOutputStream() has already been called for this response
- tomcat5下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- tomcat5下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- jspSmartUpload下载文件,出现getOutputStream() has already been called for this response 错误
- jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- 导出EXCEL:getOutputStream() has already been called for this response
- 验证码异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java导出excel报错:getOutputStream() has already been called for this response
- getOutputStream() has already been called for this response 下载excel
- 遇到问题----java.lang.IllegalStateException: getOutputStream() has already been called for this response
- tomcat6下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- java.lang.IllegalStateException: getOutputStream() has already been called for this response解决方法及解释
- java层将outputstream输出到jsp报错:getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response