This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, Havent worked on EJB's that much(although i am certified). Was just wondering, in case of Web Sessions ONE client would get the same session object thoughout the Web Application till he/she invalidates the session or it times out etc.
Just wanted to clarify the same thing in case of Sateful Session Beans. If i am a JSP/Servlet Client, and i am making multiple calls to a Stateful session bean by means of a JNDI lookup in diffrent JSP pages, will i get the same Stateful session bean ...... or do i need to store the reference of the EJBObject in a HttpSession and then use the same in diffrent JSP Pages.
Simply put... when the same client calls the same Stateful Session Bean from diffrent JSP pages in a Web App(By Means of a JNDI Lookup), does he get the same Stateful Session Bean in all cases... or does he need to store the reference of the EJBObject he got in the first place(first JSP Page where look up was performed) in a HttpSession so that its available to all JSP Pages.
Looking forward to a satisfying response.... Cheers..
Best Regards,<br />Rajnish Bhasin.<br />SCJP<br />SCWCD<br />SCBCD
Basically, what you look up through JNDI is the home of the stateful session bean. What you usually do with that home is call create() on it to create a new stateful session bean. There is no way to search for an existing stateful session bean through the home interface as you can do with entity beans. So whenever you create a new statefull session bean, you should keep it somewhere (in the session for instance) for later use since every subsequent JNDI calls would get you the home of the session bean which you can only use for creating new stateful session beans (which is not what you want).