Hi Arjun,
You can convert your code to use Servelt so as to invoke an EJB.
props = new Properties(); props.put(Context.PROVIDER_URL, "t3://localhost:7001");props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");ctx = new InitialContext(props);obj = ctx.lookup("TestApp");home = (TestHome)javax.rmi.PortableRemoteObject.narrow(obj, TestHome.class);
Have this code in the init() method of the servlet and store the home object in a member variable in the Servlet. [
You should have that code in the init method which you want to initialise once and that can be reused by all the clients, please read Servlet specs for this]
Have all other code in your service method.
Now you compile the Servlet and bundle it in a war file. Have all the classes(util classes, stubs, home and remote interface of EJBs) in the WEB-INF/classes folder and all the jars in the WEB-INF/lib of the war. Have proper servlet mapping in the web.xml for the Servlet.
Hope this is what you are looking for in the Servelt.
Cheers,
Amit Tank