File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes how to set loading message until data display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to set loading message until data display " Watch "how to set loading message until data display " New topic

how to set loading message until data display

Ramasubramaniam Rathinasubbu
Ranch Hand

Joined: Jun 09, 2010
Posts: 44
Dear all,

when i call the servlet, it is taking time for load the data. until that i wanted to give the loading message in that page.

for that what should i do?..
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

First I would try to see why it's taking so long and see if it can be sped up.

[Asking smart questions] [About Bear] [Books by Bear]
Eduardo Moranchel

Joined: Jul 31, 2012
Posts: 5
One way to do it (besides trying not to take too long on this kind of processes) is calling another page/servlet/jsp that will in turn call your heavy load servlet and display appropiate feedback to the user.

Here is how.
Lets asume right now you have 1 page and a servlet.
Page 1: form page (with a button to
ProcessHeavyStuffServlet (our slow servlet)

We have to change this by adding a couple of things. like this:

Page 1. Form page (user fills stuff and clicks next which is the heavy load stuff)
We replace the ProcessHeavyStuffServlet link with a link to a waiting page.
Page 2. Waiting page (new page)
Here we have a waiting image and we call the ProcessHeavyStuffServlet using AJAX or an IFRAME (i know they are ugly but sometimes useful)
We modify this one to store some data in the session (like the results of the execution) at the end of the execution it will tell the waiting page (using AJAX or in the IFRAME using a parent call) to go to:
page 3. Results page (new page)
We get the data that ProcessHeavyStuffServlet stored in the session and display it.

This is the theory behind those beautiful and annoying "please wait" sliders and gizmos.

Hope this helps, good luck, have fun.
I agree. Here's the link:
subject: how to set loading message until data display
jQuery in Action, 3rd edition