Servlet Exception - getOutputStream () has already been called for this response

In my servlet

exception thrown as

org.apache.jasper.JasperException: java.lang.IllegalStateException: getOutputStream() has already been called for this response


Help solve this problem



source to share

1 answer

This will happen if the call is made ServletResponse.getWriter()

while OutputStream

already being created to answer. Only one of getWriter()

or getOutputStream()

can be used to write the response body, not both.

Take a look at the stack trace associated with the exception to see if this is the case. Then if you are trying to use character data (only) getWriter()

or for a binary response use getOutputStream()




All Articles