can any one tell me how to connect a servlet to a stateless session bean in jbuilder? or just tell me what I should use? Are there books out there that have made an application to connect a servlet to a javaBean?
I. Yep. Two steps.
- Use IA and 2 if the servlet is in the same container as the
EJB.
- Use IB and 2 if the servlet is in a different container from the EJB.
1.A. IF your servlet will run in the same container as the EJB:
Context ctx = new InitialContext();
1.B IF THE EJB is in a different container (say WebLogic):
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "containeradminuserid");
env.put(Context.SECURITY_CREDENTIALS, "containerpassword");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(env);
2. In either case, get the EJBHome and have Home create the interface:
MySessionEJBHome mySessionEJBHome
= (MySessionEJBHome)ctx.lookup("MySessionEJB");
MySessionEJB mySessionEJB;
mySessionEJB = mySessionEJBHome.create( );
II. The book you want depends a bit on whose Servlet and EJB container(s) you are using. There are also Web-based instructions for different vendors. See:
http://www.javaskyline.com/learnejb.html#vend Let me know if that helps.
Regards,
Rich