• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stateful session bean client servlet

 
sai rama krishna
Ranch Hand
Posts: 411
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 746
7
IBM DB2 Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic