Reputation: 181
I want to display messsge as "Please Wait........" tilll my java code finishes some processing.
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
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);
in page3.jsp i m doing processing on userid which I got in page2.jsp simultaneously.
someid =request.getparameter(userid);
process(someid );
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.
Upvotes: 1
Views: 7532
Reputation: 4474
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>
Upvotes: 1
Reputation: 4474
I tested in IE8 and Chrome 18. If your server has restrictions, then you might have problems. For instance, it won't work on 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>
Upvotes: 0