• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to show message indicating server processing?

 
Tom George
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This must be a cliche now.

I have a jsp page, on submitting which initiates a fairly lengthy processing at the server. I want to display something to the effect of 'Please wait', and when the server processing is done, the user has to be taken to a screen which displays the results of the operation.

Sounds familiar, anyone?

Two approaches I've already tried out was,

1. Redirecting to a page when the user clicks the submit button, which has some display info like 'Please wait'. This page tries to load the other (result) screen - This was discarded as the <META> tag didnt behave properly. Also it seemed rather crude.

2. This was an even cruder hack - on clicking the submit button, some javacripting was done to unhide a <div> containing a 'Please wait'. The page continues to submit, with the progress bar at the bottom of the browser and all (yuck )

Any other ideas?
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know that your process usually takes X minutes, you can display alert message to user that this process with take around X minute � when user click on submit button.

I believe displaying hidden <div> is a good idea, because you can display a scrolling gif it in, it give better understanding to user that something is being under process.
 
Tom George
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Chetan, there is no way I can be sure of the time that would take for the processing.

So I guess the scripting is the only option left to me. But I've seen this done in many sites - online shopping for example; and I dont think they use this technique.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always try to avoid keeping the browser connection open during long running processes.

It's best to break the process off into it's own thread and then immediately return the user to a status page.
Then using either a a META-REFRESH tag or Javascript, have the page refresh every 5 or so seconds, checking on the status of the process with each refresh.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom,

AJAX is probabely the best way of doing it.
I dont have much experience with AJAX, but I can point you to a few resources on the net.

Eric, one of the JavaRanch moderators has been blogging on AJAX
http://radio.javaranch.com/pascarello/2005/07/05/1120592884938.html

And there is an example of a progress bar using AJAX on this site -
https://bpcatalog.dev.java.net/nonav/ajax/index.html

HTH

Sonny
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another crude hack, without any redirecting, would involve flushing the message to the output, and



But AJAX really is a better way if you don't mind changing the contents of the current page upon form submission, instead of switching to a different page.
 
Tom George
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your suggestions, Ben, Sonny, Yuriy..
Ajax, (with the XMLHttp at the heart of it) seems the logical solution.
Hopefully XMLHttp has grown into mature technology now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!