getOutputStream() has already been called for this response

用jsp生成验证码的时候老是报:
09:43:44 ERROR [org.apache.catalina.core.StandardWrapperValve] (StandardWrapperValve.java:274) - Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
	at org.apache.catalina.connector.Response.getWriter(Response.java:611)

在网上找到比较简单的解决方法是:
在最后面加入以下代码
out.clear(); 
out = pageContext.pushBody();

你可能感兴趣的:(OutputStream)