can anyone give me an example (simplest code possible) of using an EJB from
within jsp.
This is what we just came up with, but I was hoping for something better.
<!doctype html public "-//w3c/dtd/HTML 4.0//en">
<html>
<head>
<%@ page import="ybook.demo4.*,
java.io.*,
java.rmi.RemoteException,
javax.ejb.RemoveException,
javax.ejb.CreateException,
javax.ejb.FinderException,
javax.naming.InitialContext,
javax.naming.NamingException"
%>
</head>
<body bgcolor=#ffffff>
<% String LName = request.getParameter("LName"); %>
<% String FName = request.getParameter("FName"); %>
<%
try {
InitialContext ic = new InitialContext();
UserHome uh = (UserHome) ic.lookup ("UserHome");
User user = null;
long beginTime = System.currentTimeMillis();
user = uh.create(LName, FName);
user = null;
long elapsedTime = System.currentTimeMillis() - beginTime;
out.println("elapsed time ==> " + elapsedTime + " millis.<BR>");
} catch (NamingException e) {
out.println("NamingException caught:" + e );
e.printStackTrace();
} catch (CreateException e) {
out.println("CreateException caught:" + e);
e.printStackTrace();
} catch (RemoteException e) {
out.println("RemoteException caught:" + e);
e.printStackTrace();
}
%>
</body>
</html>
Thanx in advance,
Terrance Davis
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html