Solved

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

Posted on 2004-04-18
5
1,658 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
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 20 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now