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();
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"; }