java - 网络逻辑- 'response already committed'

标签 java jsp weblogic12c

我已在 weblogic 12c 服务器上部署了我的应用程序。我看到指向 out.clear(); 行的响应已提交错误。不确定为什么我只使用 weblogic 服务器会遇到这个问题 - 在 tomcat 上工作得很好。

下面是代码片段。任何帮助,将不胜感激!谢谢。

request.getRequestDispatcher(toolbarURL.toString()).include(request, customResponse);
Element toolbarCode = new Element("toolbarCode");
toolbarCode.setContent(new CDATA(customResponse.getOutput()));

root.addContent(toolbarCode);

XMLOutputter  outputter = new XMLOutputter(format);
out.clear();
outputter.output(new DocType("html"), out);
outputter.output(transformer.transform(doc), out);

out.clear(); 行是抛出异常的行。

最佳答案

您没有显示 out 的声明,但我假设它是一个 JSPWriter 实例。因此,您的代码依赖于 servlet 容器的某些与实现相关的行为,即它们刷新输出的速度。一旦第一个字节被刷新(向下游发送到客户端),就可能不再调用 clear (请参阅 documentation

Clear the contents of the buffer. If the buffer has been already been flushed then the clear operation shall throw an IOException to signal the fact that some data has already been irrevocably written to the client response stream.

WebLogic 12c 在刷新输出方面可能比 Tomcat 更积极。因此,清除缓冲区已经不行了。

最有可能的是,您只需删除 out.clear(); 行即可修复它。

关于java - 网络逻辑- 'response already committed',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33099979/

相关文章:

java - 检测 Scala 程序中函数变化的最佳实践?

java - [亚马逊](500310) 无效操作 : syntax error at or near "S" RedShift Error

java - 为什么我们必须将InputStream转换为ByteArrayOutputStream?

javascript - javascript中的多个 anchor 标记href值

java - 如何在jsp中迭代以下代码?

java - Weblogic Resteasy 部署问题

java - 使用PrintWriter和DataOutputStream在java中写入同一个文件

java - 获取从一个jsp到另一个jsp生成的多个值数据库下拉列表

java - WebLogic 12.2.1 中的最大帖子大小

hibernate - weblogic.management.ManagementException : There is the same running task.