给你段代码
String name = form.getName().trim();
      String pass = form.getPassword().trim();
      String npass = "";
     // 实体ejb的home 接口和 remote接口
      UsernameRemoteHome home = null;
      UsernameRemote remote = null;
      try
      {
        Context ctx = new InitialContext();
        home = (UsernameRemoteHome) ctx.lookup("UsernameRemote");
        //调用实体ejb的方法
        remote = home.findByName(name);
        System.out.println("look up success");
      }
      catch(Exception ep)
      {
        System.out.println("look up fail");
        return (actionMapping.findForward("fail"));
      }       //如果用户存在,取得其密码在进行比较
      try
      {
        npass = remote.getPassword().trim();
        System.out.println("find pass success");
      }
      catch(Exception ep)
      {
        System.out.println("find pass fail");
        return (actionMapping.findForward("fail"));
      }
      //如果密码正确,转到界面
      if (npass.equals(pass))
      {
        System.out.println("equel");
        return (actionMapping.findForward("success"));      }
      else
      {
        System.out.println(npass);
        System.out.println(pass);
        System.out.println("not equel");
        return (actionMapping.findForward("fail"));
      }

解决方案 »

  1.   

    楼上的,能在详细点嘛?或者干脆原码给我看看?[email protected]那些trim()是什么?
      

  2.   

    调用session Bean 的方法如下:Object objref=i.lookup("freev/ejb/session/leaveword/LeavewordFacadeHome");// ()中是Session Bean 的JNDI名。
    LeavewordFacadeHome home=(LeavewordFacadeHome)PortableRemoteObject.narrow(objref,LeavewordFacadeHome.class);
    // 这是是将对象的类型进行转换
      

  3.   

    InitialContext ctx=new InitialContext();
          Object objRef=ctx.lookup("helloSessionbean");
          helloSessionbeanHome home=(helloSessionbeanHome)javax.rmi.PortableRemoteObject.narrow(objRef,helloSessionbeanHome.class);
          helloSessionbean hs=home.create();
          String str=hs.helloEJB();
      

  4.   

    比如有这样一个session bean:它的jndi name是test
    在session bean里面定义了方法public int add(){};//数据库新增方法servlet调用它的过程:
    void add(){
          testHome home = null;
          test remote = null;
          try{
            Context ctx = new InitialContext();
            home = (testHome) ctx.lookup("test");//这里的“test”就是jndi name,这一步用于获得获得远程接口
            //调用session ejb的方法add()
            remote = home.add();
            System.out.println("look up success");
          }
          catch(Exception e){
            System.out.println("look up fail");        
          }
    }
      

  5.   

    这方面有什么好的书吗?
    特别是和html整合,读取数据方面的
      

  6.   


    初次访问通过JNDI查找。
    这些可以举一反三的
    一个例子够了
      

  7.   

    我认为技术的关键不是代码,而是JNDI的配置