The client program for WebLogic can be JSP / servlet, or it can be Application.
1) JSP / servlet and EJB run on the same application server, and its typical code can be as follows: (There is no need to establish a connection under T3 protocol, directly by customers
End completed)
Context ctx = new initialContext ();
Object obj = ctx.lookup ("EJB / COM / J2EE / FIRST / EJB / HelloHome");
HelloHome TRH = (HelloHome) PortableRemoteObject.narrow (Obj, HelloHome.Class);
Hello Tr = TRH.CREATE ();
Out.println (Tr.Hello ());
Note: This JNDI-NAME can be placed in Web.xml and use string jndiname = getServletConfig (). GetInitParameter ("Para-name") to get JNDI.
2) For a general Application, it is afraid that it is on the same machine as a general Application server.
Note: (1) System variables in the client must be: ../ WebLogic81 / Server / lib / weblogic.jar; otherwise you cannot run.
(2) The file configuration must be: Remote class, remote HOME class (generally does not include a bean class, ie business class) to ensure customer class run.
These files are usually organized in the form of a package, pay attention to whether the Package is correct, otherwise an error.
Its typical code can be as follows:
String URL = "T3: // localhost: 7001";
Properties Prop = New Properties ();
Prop.Put (Context.Provider_URL, URL);
Prop.Put (Context.Initial_Context_Factory, "WebLogic.jndi.wlinitialContextFactory";
Prop.Put (Context.Security_Principal, "Name");
Prop.Put (Context.Security_credentials, "CODE");
Context CTX = New InitialContext (PROP);
Object obj = ctx.lookup ("EJB / COM / J2EE / FIRST / EJB / HelloHome");
HelloHome TRH = (HelloHome) PortableRemoteObject.narrow (Obj, HelloHome.Class);
Hello Tr = TRH.CREATE ();
System.out.println (Tr.Hello ());
Note: context.security_principal and context.security_credentials are optional, involving permissions to EJB operations.