Solved

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

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

Technology Partners: 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

Multi-threading long-running processes can have a significant increase in overall performance and drastically decrease over time it takes for a process to complete. Unfortunately, not all applications support native multi-threading, some by design a…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

726 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