tomcat5下jsp出現getOutputStream() has already been called for this response異常的原因和解決方法
具體的原因就是
在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();
posted on 2007-09-03 16:42
梓楓 閱讀(409)
評論(0) 編輯 收藏