users@glassfish.java.net

Re: how I can invoke a session bean method from a JSP page in Java EE 5?

From: <glassfish_at_javadesktop.org>
Date: Thu, 20 Aug 2009 06:29:08 PDT

Hi Sarah,

The easiest thing is to define the @EJB dependency in the servlet but add a name() attribute. E.g.

@EJB(name="foo_ejb_ref")
private Foo foo;

Then you can look up the ejb in the JSP as follows :

   Foo foo = (Foo) new InitialContext().lookup("java:comp/env/foo_ejb_ref");
[Message sent by forum member 'ksak' (ksak)]

http://forums.java.net/jive/thread.jspa?messageID=361369