Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Load jsp into div tag of another jsp

 
carina caoor
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 178
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)


 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option is to learn about Ajax.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just use a JSP include?
 
carina caoor
Ranch Hand
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 300
Eclipse IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic