JSP编程-response.getWriter().flush();不起作用 [英] JSP Programming - response.getWriter().flush(); doesn't work

查看:380
本文介绍了JSP编程-response.getWriter().flush();不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

预期结果:浏览器中将显示"Hello World". 10秒后,再见幸福."显示.

Expected results: "Hello World" is displayed in the browser. 10 seconds later, "Goodbye happiness." is displayed.

会发生什么:该页面在此处加载10秒钟,然后在最后显示"Hello World Goodbye Happiness".

What happens: The page sits there loading for 10 seconds, and then "Hello World Goodbye Happiness" are displayed at the end.

我想要做的是显示达到不同里程碑时长期运行的状态.这可能吗?

What I want to do is display the status of a long-running operation as different milestones are reached. Is this possible?

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

I'm using Eclipse EE (with Tomcat) on Windows 7.

推荐答案

<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();不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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