gpt4 book ai didi

JSP 编程 - response.getWriter().flush();不起作用

转载 作者:行者123 更新时间:2023-11-28 21:51:34 29 4
gpt4 key购买 nike

<%
response.getWriter().write("Hello world<BR>\n");
response.getWriter().flush();
wait(10000); // 10 seconds
response.getWriter().write("Goodbye happiness.<BR>\n");
%>

预期结果:浏览器显示“Hello World”。 10秒后,“再见幸福”。显示。

发生了什么:页面在那里加载 10 秒,然后在最后显示“Hello World Goodbye Happiness”。

我想要做的是在达到不同的里程碑时显示长时间运行的操作的状态。这可能吗?

我在 Windows 7 上使用 Eclipse EE(带有 Tomcat)。

最佳答案

<html>
<body>
You didn't tell us which browser you were using. Chrome and Firefox behave as you expect them to do.
But, IE needs some filler at the start of the page. IE will wait for a certain amount of content to render.
I am testing with IE8 and this works for me.
<br/>
<%
out.print("Hello world<br/>");
out.flush();
Thread.sleep(3000); // 3 seconds for easy testing.
out.print("Goodbye happiness.");
%>
</body>
</html>

关于JSP 编程 - response.getWriter().flush();不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11444047/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com