Run:
  CallEJB.jsp
   

View:
CallEJB.jsp
EmployeeEJBWrapper.java
 
 
 

Calling EJB Sample 

This sample illustrates how to invoke an EJB object in JSP. It assumes /test/EmployeeBean is already deployed and published in your Oracle9i JServer. To do that, refer to $ORACLE_HOME/jsp/demo/README.

This demo makes use of the EmployeeBean EJB to lookup the employee information for a given employee number submitted by users through an HTML form.

To encapsulate the details of the jndi lookup and ejb creation there is an EJB Wrapper Bean which is also used to preserve the parameter values between iterations. To avoid performing a lookup and creation in every HTTP request, we store the EJB instance (variable testBean in the wrapper class) in the EJB Wrapper Bean instance (id employeeBean in the JSP) giving it session scope. We match the lifecycle of the HTTP Session with EJB Session using HttpSessionBindingListener.