jsp 如何吊ejb

no_com 2003-09-27 05:29:13
jsp 如何吊ejb
...全文
21 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
3kl 2003-11-24
  • 打赏
  • 举报
回复
public class ExampleEjbClient
{
public static Example getEjb() throws 异常
{
try{
Example home=(Example)HomeInterfaceFactory.create(Example.class,"XJTLMS/Example");
Exam Exam =home.create();
return Exam;
}
catch(CreateException e){
}
return null;
}
no_com 2003-11-24
  • 打赏
  • 举报
回复
在 weblogic中 :
Context ctx=null;
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");
ctx = new InitialContext(p);
Object obj=ctx.lookup("ejb的绑定名");
ExampleHome home=(ExampleHome) PortableRemoteObject.narrow (obj,ExampleHome.class);
Example ejb=home.create();
ukyer 2003-09-27
  • 打赏
  • 举报
回复
up
hxzhappy 2003-09-27
  • 打赏
  • 举报
回复
最简单的办法

Import你的ExampleEjbClient


public class ExampleEjbClient
{
public static Example getEjb() throws 异常
{
try{
Example home=(Example)HomeInterfaceFactory.create(Example.class,"XJTLMS/Example");
Exam Exam =home.create();
return Exam;
}
catch(CreateException e){
}
return null;
}


在Jsp就可以直接引用ExampleEjbClient.getEjb().(你自己的方法)

我的服务器用的是WebLogic,希望对你有帮助!
azuretitan 2003-09-27
  • 打赏
  • 举报
回复
在 weblogic中 :
Context ctx=null;
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");
ctx = new InitialContext(p);
Object obj=ctx.lookup("ejb的绑定名");
ExampleHome home=(ExampleHome) PortableRemoteObject.narrow (obj,ExampleHome.class);
Example ejb=home.create();
RobertDeNiro 2003-09-27
  • 打赏
  • 举报
回复
Properties props =new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"127.0.0.1:1099");
System.out.println("start to create context!");
Context ctx = new InitialContext(props);
System.out.println("start ejb client test");
Object obj=ctx.lookup("Example");
ExampleHome home = (ExampleHome)PortableRemoteObject.narrow(obj,ExampleHome.class);
Example example = home.create();

81,094

社区成员

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

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