java.lang.IllegalStateException: getOutputStream() has already been called for this response
来源:互联网 发布:解析域名 英文 编辑:程序博客网 时间:2024/06/16 12:21
tomcat 报错: 严重: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
是response.getWriter()和response.getOutputStream()相冲突造成的,也就是getOutputStream()方法和getWriter()方法只能用一个。根据错误描述 查看tomcat编译成的servlet文件时发现:在tomcat中把jsp编译成servlet之后在函数_jspService(HttpServletRequest request, HttpServletResponse response)的最后有一段这样的代码:
finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
这里是在释放在jsp中使用的对象,会调用response.getWriter(),因为这个方法是和response.getOutputStream()相冲突的,所以会出现以上这个异常。
解决方案如下:
在使用完输出流以后调用以下两行代码即可:
out.clear();out = pageContext.pushBody();
- java.lang.IllegalStateException: getOutputStream() has already been called for this response,java.la
- 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
- 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
- 解决异常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
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response完美解决方案
- struts2: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
- Loadrunner视频教程汇总
- 为Windows 7的winsxs文件夹瘦身,慎重。
- linux 判断文件是否存在
- Linux Kernel Source - 进程双向循环链表
- 【学习笔记】使用eclipse生成可执行的jar文件
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- 根据经纬度测算两点之间的距离
- AudioFlinger 的一个小问题
- 解决:登录角色更改导致数据查询报错
- webservice
- Logcat出错:Could not create the view: For input string: ""
- How WebKit Loads a Web Page
- cannot import name usrp解决方法
- 螺旋队列