Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Relocating a stateful bean

 
Rik Sweeney
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cart = cartHome.find()
 
Rik Sweeney
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18025
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rik Sweeney
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I'll give that a try.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic