- 浏览: 78001 次
- 性别:
- 来自: 广州
文章分类
最新评论
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
at org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:599)
at org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:163)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:122)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:115)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:190)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:115)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75)
at org.apache.jsp.showMedPic_jsp._jspService(showMedPic_jsp.java:119)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)
在此我上网也找了相关资料,但大多数都是说前面调用过getOutputStream()方法,后面又多次调用Response的getOutputStream().write(b, 0, k);方法,所以才出现提示上面的错误,其实并不是如此,我把Response.getOutputStream().write(b,0,k);改成out.write(b,0,k),还是出现同样的错误。
现在我找到解决的方案,写出来供需要的人作参考,出错原因及解决的具体方法如下:
我在tomcat5下jsp中出现此错误一般都是在jsp中使用了输出流(如输出图片,文件下载等),没有妥善处理好的原因。
原因:
在tomcat中jsp编译成servlet之后在函数_jspService(HttpServletRequest request, HttpServletResponse response)的最后有一段这样的代码
finally{
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
这里是在释放在jsp中使用的对象,会调用response.getWriter(),因为这个方法是和responsegetOutputStream()相冲突的!所以会出现以上这个异常。
解决办法:
在使用完输出流以后调用以下两行代码即可:
out.clear(); out = pageContext.pushBody();
发表评论
-
HTTPClient
2012-12-21 21:11 0public class RenRen { // The ... -
Export To Excel - Testing
2012-12-18 13:15 0MainTest ..... Map configM ... -
Export To Excel - ExcelUtils.java [Version 0.2]
2012-12-18 13:11 9import java.io.BufferedReader; ... -
Export To Excel - Action Oupt Excel
2012-11-23 13:49 10public String doAction(Work ... -
Export To Excel - ExcelUtils.java
2012-12-17 16:31 3import java.io.BufferedReader; ... -
Export To Excel - ExcelDAO.java
2012-12-18 12:55 5import java.sql.CallableStateme ... -
Export To Excel - commonExcelStyle.css
2012-12-18 12:55 6body { FONT-FAMILY: "Ari ... -
Export To Excel - ExcelConstants.java
2012-12-18 12:55 5/** * <p><b> * ... -
Export To Excel - ExcelRowList.java
2012-12-18 09:55 5import java.util.ArrayList; im ... -
Export To Excel - ExcelRowItem.java
2012-12-17 16:32 7import java.util.ArrayList; im ... -
Export To Excel - ExcelInfo.java
2012-11-23 13:50 8/** * <p><b> * ... -
Export To Excel - ExcelColList.java
2012-11-23 13:50 6import java.util.ArrayList; im ... -
Export To Excel - ExcelColItem.java
2012-11-23 13:50 11Version 0.1 import java.uti ... -
Export To Excel - ExcelCellItem.java
2012-11-23 13:49 7public class ExcelCellItem { ... -
Util
2012-12-17 16:32 676import java.io.BufferedReader; ... -
DMSUtil
2012-12-17 16:31 707import java.io.ByteArrayInputSt ... -
PooledConnectionManager
2012-12-17 16:31 926import java.sql.Connection; im ... -
FloatValidator
2012-10-05 13:42 772public class FloatValidator ext ... -
XmlHelper
2012-08-31 09:33 1268import java.io.ByteArrayInputSt ... -
XMLEncode
2012-08-30 18:43 1054public class XMLEncode implemen ...
相关推荐
纠结了半天的 java.lang.IllegalStateException: getOutputStream() has already。这个问题困扰了半天,在网上查阅了大量资料 出这个错误一般就是下面2个.....
在Java的Web开发中,`java.lang.IllegalStateException: Cannot call sendError() after the response has been committed` 是一个常见的错误,通常发生在尝试在HTTP响应已经发送到客户端之后调用`sendError()`方法...
标题 "java.lang.IllegalStateException: OutputStream already obtain" 涉及到的是Java编程中的一个常见错误,特别是当处理I/O流时。这个异常通常在尝试获取已经存在的OutputStream实例时抛出,表明该输出流已经被...
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but...
异常:Caused by: java.lang.IllegalStateException: Method has too many Body parameters Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract ...
1. java.lang.IllegalStateException: No wrapped connection. 2.java.lang.IllegalStateException: Adapter is detached. 原因: 1.单线程一次执行一个请求可以正常执行,如果使用多线程,同时执行多个请求时就会...
IllegalStateException: The specified child already has a parent.我的博客中有文章讲解
解决java.lang.IllegalStateException: unread block data的架包
Type 异常报告 消息 Failed to convert ... nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.Date': no matching editors or co
Java是一种高级编程语言,通常用于开发跨平台的应用程序。然而,有时我们可能需要在Java程序中调用操作系统底层的动态链接库(DLLs on Windows,SOs on Linux,dylibs on macOS),以便利用C、C++等语言编写的高性能...
在Java开发中,Web服务(Web Service)是一种标准的接口,允许不同系统之间进行通信,而XFire是早年流行的一款用于构建和消费Web服务的开源框架。它使用SOAP(简单对象访问协议)和XML(可扩展标记语言)作为基础,...
《Spring框架:开启Java开发新纪元》 Spring框架,由Rod Johnson创立并由Interface21公司推广,自诞生以来,它就致力于简化Java企业级应用(J2EE)的开发,提供了一种非侵入式的解决方案,极大地提高了开发效率。它...
2013-08-12 14:33:37.672:... Add CGLIB to your classpath.:java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has interface org.objectweb.asm.ClassVisitor as super class
标题中的"The full error is: java.lang.IllegalStateException"是一个典型的Java编程错误,通常表示在不合法或不适当的状态下调用了某个方法。这个错误通常暗示程序试图执行一个不能在这个特定时刻执行的操作。让...
java.lang.IllegalStateException: Invalid name=“com.alibaba.dubbo.config.ProtocolConfig#0” contains illegal character, only digit, letter, ‘-’, ‘_’ or ‘.’ is legal 原因: 如果没有指定id属性,...
这个存储库提供了一种在处理片段传输和后台任务时避免“java.lang.IllegalStateException:Can not perform this action after onSaveInstanceState”的方法。 您可以在的非常权威的阅读有关该问题和可能的解决方案...
在Java中,有两种常见的方式实现WebSocket:使用Tomcat内置的WebSocket API和使用Spring框架的WebSocket支持。下面我们将详细介绍这两种方法。 **一、Tomcat的WebSocket实现** Tomcat从7.x版本开始支持WebSocket,...
java.lang.IllegalStateException: The maximum Java version for OrientDb is Java 11. Please check current Java version meets this requirement. 参见: ...
java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader....