File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to reuse the java bean in parent page

 
Michael L. Zhang
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[removed bad (brain dead) advise]
[ January 24, 2006: Message edited by: Ben Souther ]
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh...

was thinking includes
 
Michael L. Zhang
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic