File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How do you include a JSP onload? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How do you include a JSP onload?" Watch "How do you include a JSP onload?" New topic
Author

How do you include a JSP onload?

Kelly Powell
Ranch Hand

Joined: Oct 29, 2010
Posts: 56
Hi. I have a jsp page which I want to be displayed only after the page has finished loading. I tried putting the jsp include statement at the end of my html code but it still finished loading first. Is it possible to include a jsp only after the page has finished loading? How do you do it without using any third party javascript library?

Below is how my current html looks like. The problem with this is Test.jsp is displayed first before the body. I want the body to be displayed first before Test.jsp.

What I want to happen:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

You cannot do this with any JSP mechanism; it requires JavaScript.

And while you don't need any 3rd-party library to use Ajax, doing this in jQuery is a single line, while doing it properly without a library will take dozens.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kelly Powell
Ranch Hand

Joined: Oct 29, 2010
Posts: 56
@Bear Bibeault: Thanks! Yes, I am thinking of including the JSP page using JavaScript. Unfortunately, I am not allowed to use any third party JavaScript library including JQuery. How do you include a JSP page using Javascript?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Kelly Powell wrote:@Bear Bibeault: Thanks! Yes, I am thinking of including the JSP page using JavaScript. Unfortunately, I am not allowed to use any third party JavaScript library including JQuery. How do you include a JSP page using Javascript?


Break out some JavaScript resources and learn about the XMLHttpRequest object OR use an iframe.

Eric
Bharat Chowdary
Greenhorn

Joined: Feb 13, 2011
Posts: 7
Kelly Powell wrote:@Bear Bibeault: Thanks! Yes, I am thinking of including the JSP page using JavaScript. Unfortunately, I am not allowed to use any third party JavaScript library including JQuery. How do you include a JSP page using Javascript?



As mentioned already you can use AJAX etc........

Or include the jsp like your first code...n then make the result visible only after page loading.... by calling this at the end of page "window.onload=call function tht sets properties of visiblility".

Hope this helps!!
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

bluzeee blu please check your Private messages.


SCJP, SCWCD.
|Asking Good Questions|
Kelly Powell
Ranch Hand

Joined: Oct 29, 2010
Posts: 56
@Eric Pascarello and Bharat Chowdary: Thanks for your help! Will try Bharat's suggestion to just set the visibility property of the element onload.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do you include a JSP onload?