我想将messsge显示为“Please Wait ........”直到我的java代码完成一些处理。
page1.jsp - 我的表单,我有文本框和提交按钮。 当点击提交按钮时,我正在进行表单提交并调用page2.jsp
在page2.jsp中我从page1.jsp请求参数并传递给我的java方法,该方法返回userid。
userid = myclass.mymethod();
if(userid!=null){
out.println("Record is in process.Please wait");
}
response.sendredirect("page3.jsp?"+userid=userId);
在page3.jsp中的我正在同时处理page2.jsp中的userid进行处理。
someid =request.getparameter(userid);
process(someid );
但是所有处理完成后都会显示“等待”消息。我想在userId后立即显示它。并继续对该userId进行后台处理。
答案 0 :(得分:1)
您可以使用javascript做很多事情。这是一个想法。
<html>
<body>
<div id="wait">
Some text here is necessary here for the IE browser to start displaying.
Otherwise it will wait until it receives enough of a response to begin displaying anything.
I am not sure how much padding is necessary. This works in IE 8.
<%
out.print("<little.gif' />");
out.flush();
for(int x = 0; x < 3; x++){
out.print("<br/>Processing!");
out.flush();
Thread.sleep(3000); //mock processing
}
%>
<br/></div>
<script>
alert("Finished processing.");
document.getElementById("wait").innerHTML = "Here are the results...";
</script>
</body>
</html>
答案 1 :(得分:0)
我在IE8和Chrome 18中测试过。如果您的服务器有限制,那么您可能会遇到问题。例如,它无法在Google App Engine上运行。
<html>
<body>
Some text here is necessary here for the IE browser to start displaying.
Otherwise it will wait until it receives enough of a response to begin displaying anything.
I am not sure how much padding is necessary. This works in IE 8.
<%
out.print("<loading.gif' />");
out.flush();
//mock processing
for(int x = 0; x < 3; x++){
out.print("<br/>Processing!");
out.flush();
Thread.sleep(3000);
}
%>
<br/>Finished processing. Here are the results...
</body>
</html>