Below is a sample JSP-calls-EJB that I wrote to call the employee
EJB demo in Oracle 8i. Hope this helps,
- Julie
<HTML>
<%@ page import="employee.Employee, employee.EmployeeHome, employee.EmpRecord,
oracle.aurora.jndi.sess_iiop.ServiceCtx, javax.naming.Context,
javax.naming.InitialContext, java.util.Hashtable" %>
<HEAD> <TITLE> The CallEJB JSP </TITLE> </HEAD>
<BODY BGCOLOR="white">
<BR>
<% String empNum = request.getParameter("empNum");
String surl = request.getParameter("surl");
if (empNum != null) { %>
<h2><BLOCKQUOTE><BIG><PRE>
<%= doCallEJB(Integer.parseInt(empNum),surl) %>
</PRE></BIG></BLOCKQUOTE></h2>
<HR>
<% } %>
<P><B>Enter an employee number and EJB service URL:</B></P>
<FORM METHOD=get>
<INPUT TYPE=text NAME="empNum" SIZE=10 value="7654">
<INPUT TYPE=text NAME="surl" SIZE=30 value="sess_iiop://localhost:2222">
<INPUT TYPE=submit VALUE="Ask Oracle">
</FORM>
</BODY>
</HTML>
<%! private String doCallEJB(int empno, String serviceURL) {
try {
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);
Context ic = new InitialContext (env);
EmployeeHome home = (EmployeeHome)ic.lookup (serviceURL +
"/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;}
}
%>
Nidhi Singhal wrote:
> Hi All,
>
> I am in desperate need for this information. I have been trying to dig this
> out but...
> I have an EJB which is deployed on the Oracle 8i. Now I wish to use this EJB
> in my JSP page. Can somebody please help me with this problem.
>
> Thanks
> Nidhi
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets