File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Reference To Stateful Session Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Reference To Stateful Session Beans" Watch "Reference To Stateful Session Beans" New topic

Reference To Stateful Session Beans

Rajnish Bhasin

Joined: Mar 01, 2004
Posts: 29
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....

Best Regards,<br />Rajnish Bhasin.<br />SCJP<br />SCWCD<br />SCBCD
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
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).

Does that answre your question?

[Blog] [Blogroll] [My Reviews] My Linked In
I agree. Here's the link:
subject: Reference To Stateful Session Beans
It's not a secret anymore!