aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes stateful session bean client servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "stateful session bean client servlet" Watch "stateful session bean client servlet" New topic
Author

stateful session bean client servlet

sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 282
Hi,

In stateful session bean client servlet we are explicitly setting shoppingCart to session attribute. I do not remember doing similar step withStatelessSession bean.

request.getSession(true).setAttribute("cart",shoppingCart);
I do have have annotation as well
@EJB
ShoppingCart shoppingCart

Please advice
Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 493
    
    1

It's simply a nonsense saving a stateless session bean reference in a servlet session, since, as the name implies, SLSB are stateless and thus they don't keep a conversational
state with a specific client.

I hardly used a SFSB myself - I prefer to use SLSB - but I think that you should write something like the following code:



Moreover, using



would inject in your servlet a single reference to ShoppingCart EJB, and it will not work in case of SFSB.

Hope this helps.



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stateful session bean client servlet