java.lang.IllegalStateException:已经为此响应调用了 getOutputStream() [英] java.lang.IllegalStateException: getOutputStream() has already been called for this response

查看:51
本文介绍了java.lang.IllegalStateException:已经为此响应调用了 getOutputStream()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从客户端的服务器请求加载图像时出现以下异常:

<块引用>

241132533 [TP-Processor1] 错误 [/jspapps].[jsp] - servlet jsp 的 Servlet.service() 抛出异常java.lang.IllegalStateException:已经为此响应调用了 getOutputStream()

谁能向我解释一下这个异常以及如何克服它?

解决方案

我偶然发现了这个老问题,因为我遇到了同样的问题.最后很容易摆脱异常:只需调用 out.clear() 之前:

out.clear();...//稍后,在不同的方法中ServletOutputStream out = response.getOutputStream();...

out.clear() 还帮助我摆脱了 <%@page import=... 等中的所有空行.>

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?

解决方案

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.

这篇关于java.lang.IllegalStateException:已经为此响应调用了 getOutputStream()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆