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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 56202
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to call jsp pages from java script function
 
Similar Threads
Urgent: Submitting a form in a page and using it's values in an already open page
How to open word and pdf document in the browser
jsp as a frame in jsp
Struts2 radio button allignment
RadioButtons in jsp