<%@ page import="employee.Employee, employee.EmployeeHome, employee.EmpRecord, oracle.aurora.jndi.sess_iiop.ServiceCtx, javax.naming.Context, javax.naming.InitialContext, java.util.Hashtable" %> The CallEJB JSP
<% String empNum = request.getParameter("empNum"); String surl = request.getParameter("surl"); String inJServer = System.getProperty("oracle.jserver.version"); if (empNum != null) { %>

        <%= doCallEJB(Integer.parseInt(empNum), surl, inJServer) %>
      


<% } %>

Enter the following data:

Employee Number: <% if (inJServer == null) { // not running in JServer, need a service URL %>

EJB Service URL: <% } %>

<%! private String doCallEJB(int empno, String serviceURL, String inJServer) { try { Context ic = null; EmployeeHome home = null; if (inJServer == null) { // not running in JServer, usual client setup Hashtable env = new Hashtable(); env.put(Context.URL_PKG_PREFIXES, "oracle.aurora.jndi"); env.put(Context.SECURITY_PRINCIPAL, "scott"); env.put(Context.SECURITY_CREDENTIALS, "tiger"); env.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN); ic = new InitialContext (env); home = (EmployeeHome)ic.lookup (serviceURL + "/test/employeeBean"); } else { // in JServer, use simplified and optimized lookup ic = new InitialContext(); home = (EmployeeHome)ic.lookup ("/test/employeeBean"); } Employee testBean = home.create(); EmpRecord empRec = empRec = testBean.query (empno); return "Hello, I'm an EJB in Oracle 8i.\n Employee " + empRec.ename + " earns $" + empRec.sal; } catch (Exception e) { return "Error occurred: " + e;} } %>