您先冲洗
response后再尝试冲洗
forward。容器已经将其发送
response回客户端,现在在如何
forward向另一个JSP发送请求方面陷入了困境,因此它在抛出异常的途中中止了操作。HTTP是一个
请求-响应 模型。一旦你 要求 ,你得到一个 回应 。但是,一旦 响应 已经提交,整个交易就结束了。
outStream.write(outArray); // you already committed the response here by flushing the output streamoutStream.flush();//block2request.setAttribute("Message", str1);request.setAttribute("MessageDetails", str2);// this is illegal after you have already flushed the responserequest.getRequestDispatcher("/MyFile.jsp").forward(request, response);根据Javadoc:
IllegalStateException-如果响应已经提交。
在EDIT1之后:
不,你不能两者都做。您需要决定想要什么。将字节写入响应设置正确的HEADERS和MIME-
TYPE。您无法从相同的响应中获得浏览器下载内容以及显示JSP页面。



