aspose file tools*
The moose likes JSP and the fly likes need to create a JSP waiting page on the button click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "need to create a JSP waiting page on the button click" Watch "need to create a JSP waiting page on the button click" New topic
Author

need to create a JSP waiting page on the button click

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
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

Joined: Jan 08, 2009
Posts: 1479
    
    6

Does ajax help?


Swastik
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

You can either employ Ajax as suggested (most modern method), or initiate the long action from the waiting page.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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

Joined: Jul 07, 2012
Posts: 670
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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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

Joined: Jul 07, 2012
Posts: 670


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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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

Joined: Jul 07, 2012
Posts: 670
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

Joined: Jan 10, 2002
Posts: 61769
    
  67

A forward will not work. You need to create a new request so that the waiting page remains visible.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 670
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

Joined: Jan 10, 2002
Posts: 61769
    
  67

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

Joined: Jul 07, 2012
Posts: 670
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

Joined: Jul 07, 2012
Posts: 670
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

Joined: Jun 25, 2001
Posts: 16308
    
  22

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need to create a JSP waiting page on the button click