---
title: "java.lang.IllegalStateException: getOutputStream() has already been called"
author: "minsifansi"
date: "2010-06-11T15:44:47Z"
tags: []
categories: ["非技术"]
slug: "java-lang-illegalstateexception-getoutputstream-has-already-been-called"
draft: false
lastmod: "2010-06-11T15:47:17Z"
id: 689846
url: "https://minsifansi.iteye.com/blog/689846"
---

`java.lang.IllegalStateException: getOutputStream() has already been called for this response`

 

解决方法如下：

将JSP页面的最后两行代码的注释去掉，这两行代码的作用如下：

**out.clear()：**清空缓存的内容。

**pageContext.pushBody()：**参考API

public [BodyContent]() **pushBody**()

Return a new BodyContent object, save the current "out" JspWriter, and update the value of the "out" attribute in the page scope attribute namespace of the PageContext.

 

**Returns:**

the new BodyContent

·返回一个新的BodyContent(代表一个HTML页面的BODY部分内容）  
·保存JspWriter实例的对象out  
·更新PageContext的out属性的内容