File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to populate a jsp inside a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to populate a jsp inside a jsp" Watch "How to populate a jsp inside a jsp" New topic
Author

How to populate a jsp inside a jsp

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
I am using jsp tag libs and have a requirement that on click of an image button that button should be replaced by a separate jsp which is included in current jsp
and with in same page contents of that jsp should come
but I am facing problem as how can I invoke <jsp:include> directive on click of a button
Can any one pls give me suggestion?
Thanks in advance


SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
rahul V kumar
Ranch Hand

Joined: May 20, 2003
Posts: 82
How about using IFrames?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
but I am facing problem as how can I invoke <jsp:include> directive on click of a button

You can't - the button is on the user side and jsp:include is on the server side.
Perhaps you can keep the included jsp output invisible until the button is clicked using JavaScript.
Bill
[ September 25, 2004: Message edited by: William Brogden ]
Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
i got the answer we have to refresh jsp on click of button and while refreshing it we put some flag which if true can allow the jsp:include to become active
correct me if i am mwrong
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'd bet you could figure out doing it that way. You might also be able to figure out how to do it on the client side with JavaScript and/or DHTML.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
The method you have thought is correct one. Use the flag to include another JSP.
Another method, to include the JSP content at the very start when this page is loaded, but keep in a hidden div. You can show these contents on the click of that button.

but the first method appears better if the contents/processing on server side for the included JSP is heavy. If it is very small, send one is better, it will aviod the network traffic.


Sanjeev Kaushik
 
jQuery in Action, 2nd edition
 
subject: How to populate a jsp inside a jsp
 
Similar Threads
java/html how to add fields when we click button
how to get refrance of a current executing thread of a servlet
Calling Java Method
multiple buttons
enabling and disabling text fields and buttons