• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I access the same stateful EJB from 2 diffrent servlets

 
lucio bosque
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

suppose I want a servlet A to populate some values in a stateful EJB and then I want servlet B to see the content of the same EJB used by servlet A , how can I do it ?

thanks
 
lucio bosque
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried the following that's from the first servlet

from the second servlet :

but when I am listing the myCart items in the second servlet I am getting only Noddels and Humos , what should I do in order to list also the things added by the first servlet
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each lookup will create a new stateful bean instance. So effectively, your two servlets are using different instances of the stateful bean. If you want to see the same state between those servlets, then you should be sharing one instance of the stateful bean.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic