0 Replies Latest reply on Jan 16, 2009 1:53 PM by Thiago Albertino

    Recover EJB Stateful

    Thiago Albertino Newbie

      Hi,

      I have a EJB stateful working in my server Jboss 5.0.
      So, I cried one application Web for be a client of the EJB. In client project has two JSP pages, one for to list the content in EJB and the other for add in EJB.

      In jsp that working for to list, call the EJB, so:

      InitialContext ic = new InitialContext();
      CarrinhoHome home = (CarrinhoHome) ic.lookup("LivrariaEAR/CarrinhoEJB/home");
      Carrinho carrinho = home.create();
      this.total = carrinho.getTotal();
      this.livrosList = carrinho.getLivrosList();
      this.nome = carrinho.getNome();


      And in jsp for to create, I do:

      public String AddCarrinho() {
      try {
       InitialContext ic = new InitialContext();
       CarrinhoHome home = (CarrinhoHome) ic.lookup("LivrariaEAR/CarrinhoEJB/home");
       Carrinho carrinho = home.create();
       this.total = carrinho.getTotal();
       this.livrosList = carrinho.getLivrosList();
       this.nome = carrinho.getNome();
       livro = new Livro(45, "Sujeiro");
       carrinho.addLivro(livro);
       } catch (Exception ex) {
       ex.printStackTrace();
       }
       return "listLivro";
      }


      I need to find the same EJB for the jsp that list the content and the jsp that create the content. And for each client one EJB different.

      Help me please.