aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Relocating a stateful bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Relocating a stateful bean" Watch "Relocating a stateful bean" New topic
Author

Relocating a stateful bean

Rik Sweeney
Ranch Hand

Joined: Sep 04, 2001
Posts: 36
I am making a small online bookstore and am using a Stateful Session for the shopping cart. The problem is that when I an item to the cart my other items vanish. I take it that I am creating another instance of the bean and not accessing the old one since I am using "cart=home.create()". Is there a way to find the old bean?
Thanks
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
cart = cartHome.find()
Rik Sweeney
Ranch Hand

Joined: Sep 04, 2001
Posts: 36
Sorry but I can't get this to work, is there an example anywhere that I can look at or could you explain it in a bit more detail please? Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Try saving the cart session bean's handle in your JSP or servlet session context. First time in, when you go to lookup the handle, it will be null, because you haven't saved one yet, so you find the home interface and do a create() and save the created bean's handle. Subsequently, all you have to do is get the bean from the handle.


Customer surveys are for companies who didn't pay proper attention to begin with.
Rik Sweeney
Ranch Hand

Joined: Sep 04, 2001
Posts: 36
Thanks, I'll give that a try.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Relocating a stateful bean