Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP Page load 1

Status
Not open for further replies.

Scottish

Programmer
Mar 30, 2001
2
GB
Hi to the forum,
Question: - I am trying to achieve a page load like can be seen on and was wondering if someone could either help me out or point me in the way of an online tutorial to do something the same for my site[..]
Many thanks for all replies to this question I appreciate your hard work guys!

George
 
Hi,

This effect is actually achieved using JavaScript and is quite simple.

The index.jsp file includes another JSP file called header.jsp which appears FIRST and displays an animated GIF called PleaseWait.gif. This simply shows the rotating clock on the page. To see it go to
After the include, the page continues to process the content from a series of other included JSP pages and when all have been included and the </body> tag has been sent to the browser, the <body onLoad=&quot;&quot;> event is triggered. The onLoad event only fires after all the JSP pages have been included and the end </body> tag has been written indicating the end of the content and that the page has loaded. The JavaScript in the onLoad event simply sets the src of the <img> tag in header.jsp that was showing pleasewait.gif to display null.gif which is blank, hence creating the effect of a timer.

You may notice that if you hit refresh you won't see the timer again, this is because the page has been cached and doesn't need to refresh the content. The effect is achieved because the document includes JSP pages which obviously take a few seconds to process their content.

Hope this helps!

Tiz
 
Many thanks for that Tiz, when I read through your explanation it all makes sense[..]
Once more thanks for taking the time out to reply to my query!
George
 
I have been looking for a solution for this also, but in my case it's not a matter of waiting for the page to render. Our product performs a search which takes some time server side. The user has to wait until the search is completed before any info is sent back to the browser. I'm looking for a way to display some message like expedia.com does when your searching for airline tickets. It seems like you have to bump the user to a temp page with the loading message and then when the search is completed, bring the user the result page.
 
You could create a frameset where the bottom frame has a height of zero. Then put a page in there that does a javascript timeout which forces the page to reload. Then change some text or something on the main frame.

[ta to tiz for pointing out that the rotating clock on Bfb is a simple javascript thing - it took us 2 days to figure that one out, although one of those days was spent drawing the clock]
 
We are facing the same problem lividpixel is. What i plan to do (using MVC and JSP pages) is have a page that displays random text messages and an animated GIF. In the onLoad method of the <body> tag, I will have it call the query or whatever we plan to do, so if it takes a while, the animated gif and text is still displayed. The only downside to this is making sure the gif isn't too big and itself takes a while to download. A worry I have is that the onLoad &quot;blanks&quot; the frame while going off to the browser. I don't know if it does this or not in various versions of browsers. Generally I would have to say it doesn't &quot;change&quot; the frame to the new page until its received. But it is possible that some pages you access return portions of it at a time. I prefer to get the whole returned stream at one time, rather than see portions of a page download and take a while. I think it depends on your needs. If you want portions of the page, you can set the cache flush size of a JSP page to X number of bytes which means the response buffer of the servlet will flush the contents of the response when it fills up to X bytes. Not sure what the default is either..but keep in mind that if you return a large result set from a query, you may very well want to set the buffer size of a JSP page to what you think is the maximum bytes you'll return, otherwise the browser will start receiving pages long before the full query is done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top