0 Replies Latest reply on Jan 24, 2005 3:00 AM by Enrique Fernández Corpa

    Best practice for storing EJB Stateful reference in Servlet

    Enrique Fernández Corpa Newbie

      Hi everybody,
      I'm new to Stateful EJB (I had allways worked with stateless), so when I started working with EJBSF I (wrongly) thought that every time you invoked "create" method, container was clever enough to give you the same EJB instance. Since, instead of that, a new instance is created, then I lose all the attributes stored in EJBSF. So I have some questions about this:

      1- I suppose I need to save a reference to EJBSF on client after having made ejbCreate(), but if client is a Servlet (I'm using an MVC approach) obviously I cannot save it as an attribute because Servlets are multithreaded. So which should be the best place to store this reference? Session object? Servlet context?

      2- If I save a reference to the object created, then which are the advantages of EJBSF? I could use EJBSL, do what I want invoking a bussines method, an then saving the results as well

      Thanks in advance