struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "May" <may14...@hotmail.com>
Subject call EJB from struts
Date Thu, 23 Aug 2001 02:15:16 GMT
Hello all !
Is there a recommended way to call EJB from the struts framework?

What I am doing now is...
I have StatefulSessionBean "EJB" and "EJB" has a
method getHello() which simply returns "Hello".

(1)ActionForm class
    (a) create setEJB(EJB ejb) and getEJB() methods.

(2)Action class
    (a) in the perform() method, first call the actionForm.getEJB() method.
    (b) if the result of (a) is null, create javax.ejb.Context context and
lookup EJB,
        create EJB instance.
    (c) call actionForm.setEJB(EJB ejb) method and save the EJB instance you
have
        created in (b).
    (d) call ejb.getHello() method and set the result to
        request.getSession().setAttribute("output from ejb",ejb.getHello).

(3)JSP
    (a) from JSP, call session.getAttribute("output from ejb").

Is there better way rather than setting output from EJB in Attribute?

Your experiences and suggstions will certainly be a great help !!

Thank you.
May


Mime
View raw message