怎样在JSP中调用EJB?我的代码如下,大家看看为什么错误~~

cxjxue 2002-07-11 01:10:43
<%@ page import="Converter,ConverterHome,javax.ejb.*,
javax.naming.*, javax.rmi.PortableRemoteObject,
java.rmi.RemoteException" %>
<%!
private Converter converter = null;
public void jspInit() {
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("java:yhf/applications/DefaultWebApp/Converter"); //依据部署描述生成一个对象。
ConverterHome home = (ConverterHome)PortableRemoteObject.narrow(objRef, ConverterHome.class); //建立home interface供remotor interface调用
converter = home.create(); //调用home interface中的create方法,由ejb容器去调用ejbCreate()方法,返回一个远程接口
} catch (RemoteException ex) {
}
}
%>
<html>
<head>
<title>Converter</title>
</head>

<body bgcolor="white">
<h1><center>Converter</center></h1>
<hr>
<p>Enter an amount to convert:</p>
<form method="post">
<input type="text" name="amount" size="25">
<br>
<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
<%//以下是调用remotor interface中的方法%>
<p><%= request.getParameter("amount") %> dollars are
<%= converter.DoallarToRMB(1234) %> Yen.
<p><%= request.getParameter("amount") %> Yen are
<%= converter.RMBToDoallar(2345) %> Euro.
</body>
</html>

错误信息:
cannot resolve symbol
probably occurred due to an error in /callejb.jsp line 11:
converter = home.create();
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxjxue 2002-07-11
  • 打赏
  • 举报
回复
部署了
还有我没有弄清楚weblogic(我使用的)内部是怎么把发布的ejb和外部联系起来的
也就是说JSP中怎么哪句话是把它想要EJB和它联系起来的?

另外,发布了.JAR文件后,还需要在相应的.CLASS文件吗?
如果不用了,这句话page import="Converter,ConverterHome"的作用是什么?
Andrawu 2002-07-11
  • 打赏
  • 举报
回复
你的应用程序部署了没有?如果没有部署运行是不会成功的。
cxjxue 2002-07-11
  • 打赏
  • 举报
回复
up

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧