• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need to create a JSP waiting page on the button click

 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create a wait page (Please wait page is loading) using JSP. I have a JSP page which has a button on clicking of which data gets retrieved.Now since this data retrieval takes some time.When the user is waiting for data to be retrieved I want some Message to be displayed saying "please wait while page is loading). I am unable to do this.How can do this using JSP.Please advice.
thanks
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does ajax help?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can either employ Ajax as suggested (most modern method), or initiate the long action from the waiting page.
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all. Actually since I presently do not know AJAX, is there a way to do this without AJAX?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You can either employ Ajax as suggested (most modern method), or initiate the long action from the waiting page.
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.

I will learn AJAX for that as you suggested.Just wanted to ask what you meant by the second option when you said ----"or initiate the long action from the waiting page."
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica. Shiralkar wrote:
Just wanted to ask what you meant by the second option when you said ----"or initiate the long action from the waiting page."

Traverse to the waiting page and have that page initiate the long action -- not the other way around.
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi Bear, thanks., tried this: in my JSP page i displayed a message "Please wait while page is loading" >>>> After this i performed ....a >>>>After this i coded for the long action (fetching data from Hive)


Now it displayed "Please wait" message after this the data fetched from long action got displayed but the problem is that "please wait" message has to be hidden now as data is already displayed but it would stay. This solution would be fine if i am able to hide that message once data is loaded.How to do that. is the approach same as you had suggested.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. I'd never advocate relying upon flush. Traverse to a new page for the long action. (But I almost always use the Ajax approach.)
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually that did not work.



i created a waiting page with message "please wait ........".below this i wrote

nextPage.jsp is the page where long action is there .

when i ran wait.jsp it in a moment displayed nextPage.jsp without even displaying the message in waitPage.jsp because it had got forwarded to the nextPage.jsp.





 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A forward will not work. You need to create a new request so that the waiting page remains visible.
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i had even tried..

what happnes is that next page gets called and "please wait message is not even displayed"
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A redirect won't work because you've redirected to a new page. You need to let the page display before making the new request.
 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I
i found one way and did that successfully. I set a session variable wait to true and used refresh in the page. This way the session variable wait was continuously checked for true or false and based on that it rendered the page or displayed wait message.After the long operation i removed the session variable.


The above worked fine. However now I required to do this using pop up(not displaying msg in JSP page as above).Now I have been asked to to display a pop up (with cancel button) which displays "please wait while processing is going on" and when page renders the pop up should disappear.I searched a lot on internet but didnt get how to do this.? Please advice.

Thanks again.


 
Monica Shiralkar
Ranch Hand
Posts: 866
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. actually i thought it is not just JSP question but pop up java script is involved so to post it in general java forum.Sorry for that.
 
Tim Holloway
Saloon Keeper
Posts: 18304
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fundamental problem here is that HTTP is based on a request/response protocol where a single request results in a single response. Allowing for some technical trivia, the response is an atomic transmission - all or nothing. So the very idea that you could send a request, post a "please wait..." or progress indicator and then update when the requested function is done is flawed. Until the request is actually done and the very last character of the response stream has been received by the client, the client will do exactly nothing (other than maybe a ticking-clock cursor, which isn't under your control).

To get a more meaningful form of feedback, you have to offload the long-running process to something other than the JSP/servlet logic (JSPs and servlets are forbidden from spawning threads). Then you have to create a JSP that polls this out-of-band process and indicates when the process is complete. This JSP has to be repeatedly requested (for example, via a META reload tag), because each request can only be point-in-time status query unless you want to hang waiting for completion, which simply puts you right back where you started.

If you add AJAX to the mix, the constraints remain the same. The only differences are that with AJAX, you don't have to reload the entire client page, just the interesting parts of it. And instead of using an HTML META tag to do the polling, you have a javascript polling loop on the client.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic