How to store info in a bean
1 posts in topic
Flat View  Flat View

Posted By:   john_doe
Posted On:   Wednesday, July 10, 2002 08:23 AM

How do I store info from a resultset into a bean? Any help pages or code would be appreciated. If I create a bean in one page and then I want to access it in another, is this possible without passing the bean to the other page? If not, what do I have to do if I want to use it another page or if I keep calling the same page recursively, do I need to still keep passing the bean?


Re: How to store info in a bean

Posted By:   Stephen_McConnell  
Posted On:   Wednesday, July 10, 2002 10:24 AM

Java beans in a web application have a "scope". This scope is either a "request" scope, which last from request to request or "session" scope, which lasts through the whole session.

If you create a bean (using the tag) with a "session" scope, then the bean is available to all pages in that session.

If you create the bean with a "request" scope, then you will get a brand new bean each time you access it.

So, you can create a method on lets say Bean_A which access the database and stores the values in private fields within the bean. You can then have another method which takes the other bean (Bean_B) as a parameter and sets the values needed on Bean_B.

Hope this gives you some idea on how to proceed.

Stephen McConnell

About | Sitemap | Contact