问题描述
我想将消息显示为请稍候.....",直到我的Java代码完成一些处理.
I want to display messsge as "Please Wait........" tilll my java code finishes some processing.
page1.jsp-我的表单,其中有文本框和提交按钮.单击提交按钮时,我正在执行表单提交并调用page2.jsp
page1.jsp - my form where I have text boxes and submit button. When click on submit button I am doing form submit and calling page2.jsp
在page2.jsp中,我要从page1.jsp请求参数,并将其传递给返回我userid的java方法.
In page2.jsp I am requesting parametrs from page1.jsp and passing to my java method which returns me 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.
in page3.jsp i m doing processing on userid which I got in page2.jsp simultaneously.
someid =request.getparameter(userid);
process(someid );
但是,"Wait"消息将在所有处理完成后显示.我想在获得userId后立即显示它.并继续对该用户ID进行后台处理.
But that "Wait " messge is displayed after all processing is finished. I want to display it as soon as I got userId. And continue in background processing on that userId.
推荐答案
您可以使用javascript做很多事情.这是一个主意.
You could use javascript to do many things. Here is one idea.
<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>
这篇关于显示messsge等待....随着后台处理的进行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!