你给我你的信箱,我做了一些,都是我检测过了的,需要的话可以给我发信,我会给你的[email protected]

解决方案 »

  1.   

    确切地说,从JSP调用EJB的方法有两种:
    1.JSP和EJB在同一个JVM内,即在同一台主机上,JSP可以直接调用的local方法当然也可以调用remoto中的方法.如:
    <%@page import="javax.servlet.*,javax.servlet.http.*,java.io.*,javax.ejb.*,javax.naming.InitialContext,tstlclhom.*"%>
    <% 
       tstlclhomLocalHome tstlclhomLocalhome=null; 
       tstlclhomLocal tstlclhomlocal=null;
       try{
      InitialContext ctx=new InitialContext();
          tstlclhomLocalhome=(tstlclhomLocalHome)ctx.lookup("tstlclhomLocal");
          tstlclhomlocal=tstlclhomLocalhome.create();
       }catch(Exception ex){out.print("bean出错!!!");}
     
    %><html>
      <head>
       <title>this is a EJBbean test!</title>
      </head>
      <body>
    你好!
    <%=tstlclhomlocal.getLclHel()+"  This is a   public String getLclHel();  2002.11.7"%>
      <body>
    </html>
    2.JSP和EJB在不同一个JVM内,即不在同一台主机上,JSP只能调用remote中的方法.如:
    <%@ import="java.util.*,javax.naming.*,javax.ejb.*,java.sql.*,javax.sql.*,javax.rmi.*,departmentstaff.*" %><%
        PublicSesEJBHome publicSesEJBHome=null;
       PublicSesEJB publicSesEJB=null;
       try{
         Context initial=new InitialContext();
         Object objref=initial.lookup("PublicSesEJB");
         publicSesEJBHome=(PublicSesEJBHome)PortableRemoteObject.narrow(objref, PublicSesEJBHome.class);
       }catch(Exception ex){
         throw new SQLException(ex.toString());
       }
        publicSesEJB=publicSesEJBHome.create();
    Vector tmpvector;
             tmpvector=new Vector(publicSesEJB.getDptAll());
      

  2.   

    我的系统分析员建议我在servlet中调用EJB,但是我不知道怎么做,我只用到了jsp,可他说那样不安全,具体怎么做我也不知道……
      

  3.   

    页面上自然不好调用底层得东西,一般任务都是通过servlet来分派的
      

  4.   

    怎么分派啊,能否具体点,听说stateless的session bean比较好,而且不推荐用entity bean,是这样吗,你们认为呢
      

  5.   

    实际上是这样子的,entity现在不是很流行使用。