Meaningless Drivel is fun!*
The moose likes EJB and other Java EE Technologies and the fly likes Can I access the same stateful EJB from 2 diffrent servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Can I access the same stateful EJB from 2 diffrent servlets" Watch "Can I access the same stateful EJB from 2 diffrent servlets" New topic
Author

Can I access the same stateful EJB from 2 diffrent servlets

lucio bosque
Greenhorn

Joined: Apr 28, 2010
Posts: 11
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

Joined: Apr 28, 2010
Posts: 11
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

Joined: Jul 20, 2005
Posts: 9962
    
163

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.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I access the same stateful EJB from 2 diffrent servlets
 
Similar Threads
Manage session between servlet and session bean
destroy sessionContext from EJB?
Difference between Remote & Local
Manage session between servlet and session ejb
How to maintain session info between a servlet and a session bean