代码如下:<%-- 
    Document   : index
    Created on : 2009-9-2, 14:40:05
    Author     : Administrator
--%><%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
  <%@page import="javax.naming.*,
          java.util.Properties,
          javax.rmi.PortableRemoteObject,
          java.math.BigDecimal,
          mypackage.*"%>  <html>
  <head>
  <title>
  pll
  </title>
  </head>
  <body>
  <h1>
  JBuilder   Generated   JSP
  </h1>
  <%!
  private   Context   getInitialContext()   throws   Exception   {
          String   url   =   "t3://localhost:7001";
          String   user   =   null;
          String   password   =   null;
          Properties   properties   =   null;
          try   {
              properties   =   new   Properties();
              properties.put(Context.INITIAL_CONTEXT_FACTORY,   "weblogic.jndi.WLInitialContextFactory");
              properties.put(Context.PROVIDER_URL,   url);
              if   (user   !=   null)   {
                  properties.put(Context.SECURITY_PRINCIPAL,   user);
                  properties.put(Context.SECURITY_CREDENTIALS,   password   ==   null   ?   ""   :   password);
              }              return   new   InitialContext(properties);
          }
          catch(Exception   e)   {              throw   e;
          }
      }
    %>    <%!          public   HelloWorld   create()   {          try   {
              HelloWorld = HelloWorldHome.create();
          }
          catch(Exception   e)   {
              e.printStackTrace();
          }
          return   HelloWorld;
      }
  %>
    <%       try   {
                      Context   ctx   =   getInitialContext();
                      Object   ref   =   ctx.lookup("HelloWorld");
                       HelloWorldHome = (HelloWorldHome) PortableRemoteObject.narrow(ref, HelloWorldHome.class);
                       HelloWorld = create();
                       String   allName=HelloWorld.hello("hello,this is a jsp!!!");
              }
              catch(Exception   e)   {
                  e.printStackTrace();
          }
    %>  <%       out.println("allName");%>
    
  </body>
  </html>
    
运行时提示如下:
Compilation of JSP File '/index2.jsp' failed:
--------------------------------------------------------------------------------
 
index2.jsp:55:15: 在此位置找不到任何具有此名称的变量或字段。
              HelloWorld = HelloWorldHome.create();              ^--------^
index2.jsp:55:28: 无法从 static 上下文访问此方法。
              HelloWorld = HelloWorldHome.create();                           ^---------------------^
index2.jsp:60:20: 在此位置找不到任何具有此名称的变量或字段。
          return   HelloWorld;                   ^--------^
index2.jsp:68:24: 在此位置找不到任何具有此名称的变量或字段。
                       HelloWorldHome = (HelloWorldHome) PortableRemoteObject.narrow(ref, HelloWorldHome.class);                       ^------------^
index2.jsp:69:24: 在此位置找不到任何具有此名称的变量或字段。
                       HelloWorld = create();                       ^--------^
index2.jsp:70:41: 无法从 static 上下文访问此方法。
                       String   allName=HelloWorld.hello("hello,this is a jsp!!!");                                        ^----------------------------------------^但是,HelloWorld这个ejb已经发布成功了,用客户端程序调用都成功,为什么一用jsp就不行了呢?而且我已经把HelloWorld.jar加入classpath了,还是不行。
请高手指点。