| Author |
how to reuse the java bean in parent page
|
Michael L. Zhang
Ranch Hand
Joined: Jul 06, 2003
Posts: 33
|
|
I have one index.jsp file which contains multiple frames, each frame is another jsp file, like frame1.jsp, frame2.jsp, frame3.jsp, etc.. I need only parse a single variable from a xml file in the index.jsp, most of the parsing is done in frame1.jsp, which is in a child frame. There is a java bean MyParser.java created to parse the xml, I do not want to reconnect to the xml file in the frame1.jsp since I already connected once in the index.jsp. I like to reuse the _doc object in the frame1.jsp which was created in index.jsp, how to achieve that? Can someone give me sample code statement to do this? Thanks.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
[removed bad (brain dead) advise] [ January 24, 2006: Message edited by: Ben Souther ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1008
|
|
If you are talking about using frames, with index.jsp being a frameset, and frame1.jsp being a frame in that frameset, then request attributes will not help you. There is a seperate request made for each frame of a frameset. index.jsp will run, and return a frameset to the browser. Then the browser then issues one request for each frame in the frameset. You cannot guaruntee any order in the processing of those frames. So frame1.jsp will run after index.jsp has finished. Maybe you can consider session attributes instead of request attributes? http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSession.html
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
|
Or you can get tricky and have your frames talk to each other in the browser. We're not talking JSP any more, but JavaScript. My project does a lot of stuff where one frame retrieves data and then calls JavaScript functions on the other frames to "push" the data around. Timing is an issue - it's tough to make sure the other frames have loaded and are ready to receive the push.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Doh... was thinking includes
|
 |
Michael L. Zhang
Ranch Hand
Joined: Jul 06, 2003
Posts: 33
|
|
Thanks all. Yes, request.setAttribute() is not working in this case, session is fine. But I just try to avoid session since we do not have it in other place. I am thinking other options here.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Originally posted by Michael L. Zhang: Thanks all. Yes, request.setAttribute() is not working in this case, ..
No, it won't with frames. As Stefan mentioned, each frame generates a new request. I apologize if my bad advice caused you to waste time. I was hoping to have pulled it down before you read it.
|
 |
 |
|
|
subject: how to reuse the java bean in parent page
|
|
|