jsp图片验证码实现及getOutputStream() has already been called for this response异常
2010-12-08 16:39
344 查看
这几天在做注册时,需要用到验证码,成功把验证码图片显示到画面上后,后台就抛getOutputStream() has already been called for this response异常,虽然不影响运行,但是很可恶啊,去网上找了一下,发现了一个很靠谱的解释,如下:
tomcat5下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
在tomcat5下jsp中出现此错误一般都是在jsp中使用了输出流(如输出图片验证码,文件下载等),
没有妥善处理好的原因。
具体的原因就是
在tomcat中jsp编译成servlet之后在函数_jspService(HttpServletRequest request, HttpServletResponse response)的最后
有一段这样的代码
finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
这里是在释放在jsp中使用的对象,会调用response.getWriter(),因为这个方法是和
response.getOutputStream()相冲突的!所以会出现以上这个异常。
然后当然是要提出解决的办法,其实挺简单的(并不是和某些朋友说的那样--
将jsp内的所有空格和回车符号所有都删除掉),
在使用完输出流以后调用以下两行代码即可:
out.clear();
out = pageContext.pushBody();
问题果然解决了!!!
转载自http://www.zxbc.cn/html/20071201/29949.html
tomcat5下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
在tomcat5下jsp中出现此错误一般都是在jsp中使用了输出流(如输出图片验证码,文件下载等),
没有妥善处理好的原因。
具体的原因就是
在tomcat中jsp编译成servlet之后在函数_jspService(HttpServletRequest request, HttpServletResponse response)的最后
有一段这样的代码
finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
这里是在释放在jsp中使用的对象,会调用response.getWriter(),因为这个方法是和
response.getOutputStream()相冲突的!所以会出现以上这个异常。
然后当然是要提出解决的办法,其实挺简单的(并不是和某些朋友说的那样--
将jsp内的所有空格和回车符号所有都删除掉),
在使用完输出流以后调用以下两行代码即可:
out.clear();
out = pageContext.pushBody();
问题果然解决了!!!
转载自http://www.zxbc.cn/html/20071201/29949.html
相关文章推荐
- jsp图片验证码实现及getOutputStream() has already been called for this response异常
- jsp图片验证码实现及getOutputStream() has already been called for this response异常
- jsp图片验证码实现及getOutputStream() has already been called for this response异常
- 登录页面验证码的简单实现,以及getOutputStream() has already been called for this response异常的解决方法
- 生成图片验证码jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- Java读取数据库Blob对象返回到JSP页面和getOutputStream() has already been called for this response异常处理
- 生成图片验证码jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- 验证码 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异常的原因和解决方法
- jspsmart下载文件出现getOutputStream() has already been called for this response的解决
- struts2中getOutputStream() has already been called for this response异常解决方法
- tomcat6下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- tomcat5下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- 验证码 getOutputStream() has already been called for this response异常的原因和解决方法
- tomcat5下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- tomcat6下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- 在jsp中使用response.getOutputStream()导致报错问题getOutputStream() has already been called for this response
- getOutputStream() has already been called for this response异常的原因和解决方法
- getOutputStream() has already been called for this response异常的原因和解决方法