Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes Displaying progress when loading JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying progress when loading JSP" Watch "Displaying progress when loading JSP" New topic
Author

Displaying progress when loading JSP

Lijun An
Greenhorn

Joined: Feb 05, 2002
Posts: 15
Hi there,
How do I display progress on the page when a JSP is being loaded? The JSP page will process a lot of data before it is loaded into browser. I'd like to display a progress bar to tell the user to be patient.
Please comment.
Thanks,
Lijun
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The problem with JSPs (and HTTP in general) is there is a clear separation between code on the client server and code on the client.
That is, you cannot generally have code running on each end depending on each other. A request is sent to the server, it processes the request and a response is sent back to the client.
The best way I've encountered to do this is to use an intermediate 'Please Wait' page. Essentially the client sends a request to a 'fake processing servlet', this servlet returns a 'please wait' page and sends the original request to the real processing servlet.
The advantage here is that the 'Please wait' page is the one that is displayed while the long processing takes place.

DOM
Lijun An
Greenhorn

Joined: Feb 05, 2002
Posts: 15
Thanks a lot, DOM.
I understand that your approach is using a fake process servlet. That's fine. What if the process servlet/JSP is the JSP itself? How do I achieve displaying the progress to the client essentially in the same page?
Regards,
Lijun
Lijun An
Greenhorn

Joined: Feb 05, 2002
Posts: 15
Hi DOM,
Would you please tell me why the form 'auto' has two actions? I'm quite confused.
Thanks,
Lijun
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Oops, cut and paste error...
DOM
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

Servlets and JSPs are expected to turn around rapidly. If they don't the user's browser will time out and the work gets lost. This is why long-running processes should be sent to back-end servers instead of being handled in the JSP code itself. Since HTTP does not support the back-end server volunteering any information, this means that you have to keep polling for information, and the easiest way to do that is by using a timed-refresh web page.
Once the data is complete and in the process of being transmitted back, the webapp is no longer involved. However in some web browsers, the browser itself will show how far along the actual transmission is.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
GeeCON Prague 2014
 
subject: Displaying progress when loading JSP