今天在调试一个小web项目时,验证码不显示了,而且后台报错

getOutputStream() has already been called for this response

经过查找得知:

在tomcat6.0下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();

参考博客:使劲点我啊

getOutputStream() has already been called for this response异常的原因和解决方法的更多相关文章

  1. jsp出现getOutputStream() has already been called for this response异常的原因和解决方法

    jsp出现getOutputStream() has already been called for this response异常的原因和解决方法 在tomcat5下jsp中出现此错误一般都是在js ...

  2. ASP.NET中使用UpdatePanel时用Response输出出现错误的解决方法

    asp.net中执行到Response.write("xx");之类语句或Microsoft JScript 运行时错误: Sys.WebForms.PageRequestMana ...

  3. IE下获取不到Response添加的cookie的解决方法

    原博客地址: http://blog.csdn.net/wjdd1/article/details/16341189 在百度上查询了好久也没有查询到结果,于是自己用ie的开发者工具进行跟踪,JSESS ...

  4. 安装Yii2提示Failed to decode response: zlib_decode(): data error错误解决方法

    如果是根据官方文档来安装(composer create-project --prefer-dist yiisoft/yii2-app-basic basic),并提示此错误的话,那么请做: 1. 请 ...

  5. 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response

    严重: Servlet.service() for servlet jsp threw exception    java.lang.IllegalStateException: getOutputS ...

  6. getOutputStream() has already been called for this response解释以及解决方法

    异常:getOutputStream() has already been called for this response 的解决方法 今天在第一次接触使用“验证码”功能时,在执行时出现了异常信息: ...

  7. 解决getOutputStream() has already been called for this response

    http://qify.iteye.com/blog/747842 —————————————————————————————————————————————————— getOutputStream ...

  8. getOutputStream() has already been called for this response 从了解到解决

    一.背景说明        在tomcat的localhost.log日志中时长见到 getOutputStream() has already been called for this respon ...

  9. 关于:org.apache.catalina.connector.ClientAbortException及getOutputStream() has already been called for this response的异常处理

    1.异常场景: 在进行将数据用word导出或者Excel导出的时候.抛出的异常getOutputStream() has already been called for this response 导 ...

随机推荐

  1. CentOS 5.6 安装Oracle Java 和 Eclipse

    1.卸载原有OpenJDK 1. 使用java  -version查看当前Java版本信息 2. 使用rpm  -qa  |  grep  java 列出所有被安装的java rpm package ...

  2. 二叉搜索树算法详解与Java实现

    二叉查找树可以递归地定义如下,二叉查找树或者是空二叉树,或者是满足下列性质的二叉树: (1)若它的左子树不为空,则其左子树上任意结点的关键字的值都小于根结点关键字的值. (2)若它的右子树不为空,则其 ...

  3. nyoj 79 拦截导弹

    拦截导弹 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 某国为了防御敌国的导弹袭击,发展中一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到 ...

  4. [Objective-c 基础 - 2.6] @property和@synthesize

    Xcode编译器的特性,自动生成getter和setter   A.@property 自动生成某个成员变量的getter和setter的声明 变量的命名要求:以下划线开头 Student.h @in ...

  5. swift 内存管理,WEAK 和 UNOWNED

    因为 Playground 本身会持有所有声明在其中的东西,因此本节中的示例代码需要在 Xcode 项目环境中运行.在 Playground 中可能无法得到正确的结果. 不管在什么语言里,内存管理的内 ...

  6. 转载 DNS查询流程简介

    转载请注明出处:http://blog.csdn.net/luotuo44/article/details/45545059 DNS(domain name system),读者们或多或少都听过,就是 ...

  7. IE6完美解决fixed方法

    ie6对position:fixed不支持,网上有很多解决方法,有的在ie6,ie7上调试成功后,在ie8上又不好使,div层还是跟随滚动条浮 动:以下总结方法,在ie6,ie7,ie8上都调试成功, ...

  8. loadmore

    实例点击 loadmore.js /* * loadmore.js require jQuery,artTemplate * Butterfly 2013.08.28 */ define(['../u ...

  9. ISE和Modelsim联合仿真(转)

    相信很多人会遇到过这个问题,不知如何让ISE调用Modelsim进行仿真.我也迷糊了不少时间,查查找找,终于弄明白了,所以有了本文,和大家分享一下.我尽量讲得详细点儿,多多上图. 我的环境:Windo ...

  10. C++学习笔记(十一):void*指针、类型转换和动态内存分配

    void*指针 void关键字表示“空类型”的概念.但是,这里的“空类型”不表示“任意类型”,而是表示不存在的意思,也就是说C/C++不允许你写语句void a,不存在类型为void的东西. void ...