• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call jsp pages from java script function

 
A Chauhan
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've a Jsp page which is having radio buttons.Upon clicking one radio button,it should include(display result inthe same page)a jsp page and upon clicking another radio button it should include another jsp file in the same area.

I don't know how to place "<jsp:include file="somefile.jsp"/>" using Javascript
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by amrish jain:

I don't know how to place "<jsp:include file="somefile.jsp"/>" using Javascript


You can't.
Javascript is interpreted in the browser, on the client's machine, after the JSP has finished building the page and has sent it from the server to the client. In other words, by the time the Javascript interpreter starts parsing your page, the JSP is finshed, gone, and no longer in the picture.

I'm going to move this thread to our HTML/Javascript forum.
What you want to do could be achieved with Ajax and that would be the forum for Ajax discussions.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could this one of two ways:

1) Use an iframe into which you load the "sub-page" upon a click of the radio button.

2) Use Ajax to fetch the page fragment to display and put in into a portion of the main page reserved to display it.

If you already have the sub-pages coded as full HTML pages, option 1 is probably the easiest course.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic