Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-18
5
Medium Priority
?
1,668 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 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