tomcat6下jsp出现getOutputStream() has already been called(2)

OutputStream output=response.getOutputStream();
while((len=in.read(b)) >0) {
  output.write(b,0,len);
}
output.flush();


而不是把response.getOutputStream().write()放到循环体内

在页面中直接写:

复制代码 代码如下:

<body bgcolor="#ffffff">
<h1>
<%
    response.getOutputStream();
%>
</h1>
</body>

将会出现错误消息如下:

java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.catalina.connector.Response.getWriter(Response.java:604)
org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)

以上就是tomcat6下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法的全部内容,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzjpdy.html