Servlet的“响应已经承诺”的原因 [英] Cause of Servlet's 'Response Already Committed'
问题描述
响应已被提交,因为以下原因:
-
因为响应缓冲区已达到最大缓冲区大小。可能是因为以下原因:
> JSP页面中的bufferSize已达到。您可以在page指令中增加JSP缓冲区大小
。看到这里,
<%@ page buffer =5kbautoFlush =false%>
>服务器默认响应最大缓冲区大小已达到。您可以增加
服务器默认的最大缓冲区大小。
ServletRespnse.setBufferSize()
-
部分代码已经调用了响应,我e,调用方法
HttpServletResponse.flushBuffer()
。 -
某些部分的代码已经刷新了
OutputStream
或Writer
,i,e调用方法HttpServletResponse.getOutputStream()。flush()
或`HttpServletResponse.getWriter()。flush() -
转发到另一个页面,其中响应被提交和关闭。例如,当response.sendRedirect()被调用时,响应被提交。
What are the common possibilities to encounter this exception in servlet - Response Already committed?
The response gets committed because of the following reasons:
Because the Response buffer has reached the max buffer size. It could be because of the following reasons:
> the bufferSize in JSP page has reached.You can increase the JSP buffer size in page directive. See here, <%@ page buffer="5kb" autoFlush="false" %> > the server default response max buffer size has reached.You can increase the server default max buffer size. ServletRespnse.setBufferSize()
Some part of the code has called flushed on the response , i,e, invoked the method
HttpServletResponse.flushBuffer()
.Some part of the code has flushed the
OutputStream
orWriter
, i,e, invoked the methodHttpServletResponse.getOutputStream().flush()
or `HttpServletResponse.getWriter().flush()If you have forwarded to another page, where the response is both committed and closed. For example, when response.sendRedirect() has been called, the response is committed.
这篇关于Servlet的“响应已经承诺”的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!