I am playing around stateful session beans. So building a shopping cart simple demo for that. I am new to EJBs. So need to clear a doubt. We know Stateful session beans are used for more than one conversation between client and server. Here client is a Servlet. So when user first time enters or adds an item to cart, i fire a create(some arg, may be user name) and get a ref to remote component stub. Now item is added first time. and my first request to web client is done. The item is finally added in Session bean 's list.
We know that http is stateless. Next time, i cant get ref to remote component stub to the same bean. So do i need to store it into HttpSession for the same user session till the time user say confirm for all items and when user confirm, finally after buying those items, i need to call remove on ref to remote component stub or on home stub with Handle.
Please correct me if i am wrong here or tell me some good technique of this.
Thanks Pawan SCJP5.0, SCWCD 1.4 TARGET: EJB2.0 and the EJB3.0
I am new to EJB but I have also been thinking about servlets and session EJBs.
I think you are right: you need to store your stateful session bean's reference in the web application's session scope. Then when you are done using it, you should call one of the remove methods (e.g., one of the stateful session's beans methods annotated with the @Remove annotation) and then remove your stateful session bean's reference from session scope. [ May 13, 2008: Message edited by: Sergio Tridente ]