0 Replies Latest reply on Nov 30, 2006 5:00 AM by Radovan Zelig

    EJB3Trail question about stateful bean

    Radovan Zelig Newbie

      In JBoss 4.0.5 GA (ejb3 profile)
      I consider the following code in the EJBTrail example (inside the jsp calculator page that call a Stateful Calculator bean):

       Calculator cal =
       (Calculator) session.getAttribute("sfsb_cal");
       if (cal == null) {
       try {
       InitialContext ctx = new InitialContext();
       cal = (Calculator) ctx.lookup(
       session.setAttribute ("sfsb_cal", cal);
       } catch (Exception e) {
       e.printStackTrace ();

      If I call a jndi lookup each time the page is rendered : I change :
      Calculator cal =
       (Calculator) session.getAttribute("sfsb_cal");

      Calculator cal = null;

      Then I get a new Stateful bean each time the page is rendered ... Isn't that contradictory with the fact that one Stateful bean should created by session ?

      I think there is something that I dont understand here ... I'll be glad to get some pointers here ;-)