| Author |
Load jsp into div tag of another jsp
|
carina caoor
Ranch Hand
Joined: Jun 23, 2007
Posts: 300
|
|
I want to load a jsp page into div tag of another jsp using the onload event for this i have used
but the above is not working and i am getting the file name BatchJobControl.jsp as text in the div tag instead of the page getting loaded.
Please suggest me how do i load a jsp into div tag.
|
 |
marten kay
Ranch Hand
Joined: Feb 03, 2007
Posts: 168
|
|
the code
document.getElementById('bjdivload').innerHTML = '/BatchJobControl.jsp';
doesn't actually 'call' the jsp, the innerHTML property just takes this as a string literal, so that is why you are seeing the string /BatchJobControl.jsp
the resulting html would simply look something like this
I'm not too sure if what you are attempting is possible in such a simple way, I would suggest using an iFrame and set the window.location = "....../BatchJobControl.jsp" for it, or, pull the html of the server in the form of a string using ajax and then use the innerHTML property to place that string inside the selected element (this is what I do but I don't use a jsp, I build the string directly)
|
when in doubt put it in parenthesis and stick a dollar sign in front of it, only good can come from this.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
Another option is to learn about Ajax.
Eric
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
Why not just use a JSP include?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
carina caoor
Ranch Hand
Joined: Jun 23, 2007
Posts: 300
|
|
When i just include the page .. the included page's onLoad event is not getting fired? even if i use Ajax the onload in not getting fired.
How do i fire the onload event of the included page...
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
You can not just stick an entire page into the page with innerHTML and expect it to work. First it is invalid html [think you have html inside of html and heads and bodies galore. Second inline JavaScript is not executed since there is no load event.
I think you would be better off with an iframe.
Eric
|
 |
carina caoor
Ranch Hand
Joined: Jun 23, 2007
Posts: 300
|
|
|
The main jsp in which i am including child jsp is under a particular tab. and when i navigate between tabs the iframe(present in main jsp) is loading the child jsp again. I dont want to load the page even if navigate between tabs thats the reason i dont want to use iframe.
|
 |
 |
|
|
subject: Load jsp into div tag of another jsp
|
|
|