• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to call a EJB from a servlet  RSS feed

 
pramod m.s
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

i have a small problem.

i went through ed romans book,

i am finding it difficult to call a EJB from a servlet.

can anyone pls help me.

thanking u in advance
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call EJB in Servlet as in anyother client program. Look up the home interface from the JNDI and then create the Bean's instance using that home interface.

InitialContext ctx = new InitialContext(properties);

use this InitialContext object ot lookup your bean ctx.lookup("name");

and then Narrow using PortableRemoteObject class. Same as in anyother client.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!