日期:2014-05-16  浏览次数:20365 次

JSP和APPLET如何通讯
JSP如何与EJB SessionBean通讯
下面的代码段作了很好的示范
<%@ page import=”javax.naming.*, javax.rmi.PortableRemoteObject,
foo.AccountHome, foo.Account” %>
<%!
//定义一个对SessionBeanHome接口实例的全局引用
AccountHome accHome=null;
public void jspInit() {
//获得Home接口实例
InitialContext cntxt = new InitialContext( );
Object ref= cntxt.lookup(”java:comp/env/ejb/AccountEJB”);
accHome = (AccountHome)PortableRemoteObject.narrow(ref,AccountHome.class);
}
%>
<%
//实例化SessionBean
Account acct = accHome.create();
//调用远程方法
acct.doWhatever(…);
// 如此等等
%>