Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in Stateful Session Beans  RSS feed

 
Sai Surya
Ranch Hand
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am implementing a stateful session bean for my shopping cart application. My requirement is to persist the data across many sessions. I mean, for each user login, the user should be able to see other user's cart items. Is it possible with stateful session beans? Or do I need to implement this without stateful session beans? Which approach is faster?

Thanks in advance,
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Stateful session bean will keep an instance per session. You will only have access to that instance's state if you have the session that owns it. So no, there is no easy way to share an instance between multiple sessions. You might try some sort of persistent store (such as a database) for your cart data instead.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!