Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you include a JSP onload?

 
Kelly Powell
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64822
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kelly Powell
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bluzeee blu please check your Private messages.
 
Kelly Powell
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Eric Pascarello and Bharat Chowdary: Thanks for your help! Will try Bharat's suggestion to just set the visibility property of the element onload.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic