How do I obtain a new stateful session bean in a servlet thread?
Posted
by FarmBoy
on Stack Overflow
See other posts from Stack Overflow
or by FarmBoy
Published on 2010-05-14T10:39:15Z
Indexed on
2010/05/14
10:44 UTC
Read the original article
Hit count: 451
I'm experimenting with EJB3
I would like to inject a stateful session bean into a servlet, so that each user that hits the servlet would obtain a new bean.
Obviously, I can't let the bean be an instance variable for the servlet, as that will be shared. And apparantly injecting local variables isn't allowed.
I can use the new operator to create a bean, but that doesn't seem the right approach.
Is there a right way to do this? It seems like what I'm trying to do is fairly straightforward, after all, we would want each new customer to find an empty shopping cart.
© Stack Overflow or respective owner