aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to call jsp pages from java script function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to call jsp pages from java script function" Watch "How to call jsp pages from java script function" New topic
Author

How to call jsp pages from java script function

A Chauhan
Greenhorn

Joined: Nov 21, 2006
Posts: 15
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call jsp pages from java script function