This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

how to reuse the java bean in parent page

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[removed bad (brain dead) advise]
[ January 24, 2006: Message edited by: Ben Souther ]
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh...

was thinking includes
 
Michael L. Zhang
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic