Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Flush...

 
Mandy Smith
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am inserting a bunch of records into the database and i know it takes a long time to insert. So i want something like wait message(Please wait...) to be viewed by the user rather than viewing just the blank page while its inserting records to the database.
I am using a servlet to do this. So just before the database insert statement i output this message saying (Please wait... ) on to the servletOutputStream and then flushing it.
out.println("Please wait . . .");
out.flush()
Soon after the insert is finished, i wan't that output to be displayed basically saying Num of successful inserts and Num of Error records.
My problem is, it's not outputting this "Please wait ..." message at the start of database inserts at all. This message is output along with the database status.
So my question is how to make this happen? For some reason flush() is not working here.
Any idea???
Appreciate your help,
Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a few ideas:
1) When the request for the information is made, direct the request to a page that contains your "please wait..." message which in turn makes the actual request that will display the info. This way, while the info is being gathered, the intermediary page is being displayed.
2) An IE-only solution that I've used in the past when I knew that the web app was going to be used in an IE-only environment is a bit more complex and relies upon the page being a JSP.
I created a DIV with its display style initially set to visible. The visual style of this div made it look like a message box on the screen. The actual info was included into this page using a jsp:include directive. Once the included sub-page loaded, it invoked a javascript method that set the display mode of the "box" to invisible.
The effect is that the box would display immediately, and stay visible while the "sub-page" was loading. Once the sub-page loads, the "box" disappears.
This solution may be too fragile for general use. It relies upon IE-only capabilites (or at least Netscape 4.x can't change the page dynamically like this), and it relies upon the response output getting flushed to the browser before processing the jsp:include for the sub-page.
It worked fine in the environment in which it was deployed (controlled in-house web app, caucho resin container), but I'm not sure if I'd rely upon it in a broader environment. But I figured I'd relay this in case it's something you want to play with.
hth,
bear
[ April 08, 2002: Message edited by: Bear Bibeault ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about sending your "Please wait..." with some HTML markup so the browser will know what to do with it? Like "<p>Please wait....</p>
Bill
 
Mandy Smith
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. It works fine now. I just did what William Brogden said.
Thanks again for your reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic