Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
713 views
in Technique[技术] by (71.8m points)

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

I get the following exception when I'm trying to request loading images from server on client side:

241132533 [TP-Processor1] ERROR [/jspapps].[jsp] - Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response

Can any one explain this exception to me and also how to get over it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I just stumbled upon this old question as I had the same issue. In the end it was quite easy to get rid of the exception: Just call out.clear() before:

out.clear();
...
// later, in a different method
ServletOutputStream out = response.getOutputStream();
...

out.clear() also helped me to get rid of all those empty lines from <%@page import=... and the like.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...