It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes Loading a page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Loading a page" Watch "Loading a page" New topic
Author

Loading a page

phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have a jsp page called main.jsp.In this page I have a href link which calls another jsp page first.jsp. When I click this first.jsp, it takes some time to laod. while loading, how can I show a message "Loading, Please wait".

How can I achive this?

Please suggest me with some example

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

You can put a hidden div that's positioned wherever you want on the page, and reveal it just before the link is submitted via the onclick handler of the link.
[ June 02, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
Could you please give me some examples? So that it would be easy for me to handle it.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

What have you got so far? All you need to do is create a block containing your "Loading..." message with its CSS display property set to none. Then, in the onclick handler, set the property to block.
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
here is the code for the main.jsp which calls
<br>
<a href="StartPage.jsp"><font size=3 face="Times" color="990033"> <center> <b> main apge </b></center></font></a>
<br>

while loading StartPage.jsp page, I need to show the status of loading page

So where you wnat me to write DIV here

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Wherever you want it to appear.

Umm, you do realize that the font tag is deprecated? Why are you using such old HTML? Are you not up-to-speed on CSS?
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
Can you please help me in doing that? I don't understand, how to start also. I never use the DIV before.
I want to show the laoding message when I click the startpage.jsp.


I appricate you'r help

Thanks a lot.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

If you don't know how to write basic HTML, I'd suggest that you bone up on HTML before trying to dive off into more advances topics like event handling.
darshan karle
Greenhorn

Joined: May 09, 2008
Posts: 28
hi lakshmi
may be this code will help you.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style type="text/css">

div.test{
display:none;
}

</style>

<script>
function doValidation()
{
document.getElementById('mydiv').
document.getElementById('mydiv').style.display = 'block';
}
</script>
</head>
<body>

<input type="submit" "<"onclick "<"="doValidation()"><br><br>

<div id="mydiv" class="test" ><h3>This is a test!<br>Can you see me?</h3></div>



</body>
</html>
darshan karle
Greenhorn

Joined: May 09, 2008
Posts: 28
hi lakshmi

sorry for one mistake.actually there are two lines starting with
document.getElementById('mydiv'). in java script.
please remove the first line which is incomplete

regards
darshan
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
Thanks for you help, I have modified the code below, with a href. Is that ok?


<a href ="startpage.jsp" "<"onclick "<"="doValidation()"><br><br>

<div id="mydiv" class="test" ><h3>This is a test!<br>Can you see me?</h3></div>
[ June 03, 2008: Message edited by: lakshmi manepally ]
Usman Saeed
Ranch Hand

Joined: May 21, 2008
Posts: 31
Hi lakshmi, i made lots of tries to upload code regarding your problem but i am afraid its very user unfriendly way to add code in reply on this forum.

[Edit: Please read this.]
[ June 03, 2008: Message edited by: Bear Bibeault ]

Usman Saeed
darshan karle
Greenhorn

Joined: May 09, 2008
Posts: 28
hi lakshmi,

darshan here ,i javaranch i cannot paste the code as it is.to avoid virus they have done like that.

in the code i have pasted please....... make one change.
before and after onclick there is left arrow between double quote.remove left arrow along with double quotes.it will work fine

good luck.
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have already did that. Actually, my problem is when I click the submit button, it calls the jsp page.But it is loading the page for a long time. Is there any way I can make the page loading faster.

OR while loading the page I want to show some message on the status bar. The page is laoding please ..wait.

How is it possible? Please let me know


Thanks a lot.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Speeding up the response is a server-side issue. Have you profiled the code to see where the bottle-necks may lie?
[ June 04, 2008: Message edited by: Bear Bibeault ]
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
Actually the page it is loading has some drop down values coming from the database.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Database access can be lightning fast or excruciatingly slow depending upon too many factors to count. In order to find out where the slowness is coming from, you need to measure where in the code the bottleneck is. Profiling tools are designed for just that,
lina ajay
Ranch Hand

Joined: Apr 04, 2008
Posts: 31
Originally posted by lakshmi manepally:
Actually the page it is loading has some drop down values coming from the database.

try this with the former code given by darshan.
function A() {

document.getElementById("mydiv").style.visibility = 'visible';
document.getElementById("currentpage").style.visibility= 'hidden';

return;
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading a page
 
Similar Threads
how to run jsp from unix/weblogic server
Loading Time
greyed buttons
Passing values to JSp with href
how to run jsp fron unix /weblogic