?
Solved

How to show a "Loading..." icon when page is loading?

Posted on 2004-04-18
5
Medium Priority
?
1,667 Views
Last Modified: 2008-02-26
I have used the following code, but I still get a blank page when the data is loading. How do I display a "loading..." when the data is loading and disappear after that?

<%

  out.println("Loading...");

  String recordSQL = "SELECT * from BS_PERSON ";                                                    
  ResultSet rset = CM.executeQuery(recordSQL);
  while (rset.next()) {
      out.println(rset.getString("USERNAME");    
  }
 %>

Thank you.
0
Comment
Question by:Tuan_Jean
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 7

Expert Comment

by:searlas
ID: 10857692
This needs two answers.  First, to get "Loading..." displayed straight off you need to call out.flush() straight after your "Loading..." println (required, because your JSP output is probably bufffered by default.)

Secondly, getting the 'Loading...' message to disappear after the page has loaded.  One option is to wrap the 'loading' message in an HTML tag (div/span/h1 etc.) and then use a Javascript onload handler to hide it, like this:

<body onLoad="document.getElementById('loading').style.display = 'none'">
<div id="loading">Loading....</div>
<%
  out.flush();
  String recordSQL = "SELECT * from BS_PERSON ";                                                    
  ResultSet rset = CM.executeQuery(recordSQL);
  while (rset.next()) {
      out.println(rset.getString("USERNAME");    
  }
%>
0
 
LVL 1

Expert Comment

by:cpuburst
ID: 10859606
Hi Jean,

Suppose, If you have two pages, a.jsp and b.jsp, Put a page in between them, say loading.html
which displays whatever message or image you want to show to the user viz. "Page is loading..please wait."

Now a.jsp has to submit to loading.html and in the body onload event of loading.html, submit, the form in loading.html
to b.jsp. This will ensure, the user sees the loading.html until b.jsp processing is done and data flushed to the client.

Cheers
Cpuburst
0
 
LVL 6

Accepted Solution

by:
jarasa earned 80 total points
ID: 10860337
0
 

Author Comment

by:Tuan_Jean
ID: 10864737
Thank you all for your answer. I have tried the out.flush method and it does not work very well because I can see loading... and the records together.

How can I split the points for cpuburst and jarasa?
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10866520
I guess is too late now.
Javier
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question