This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes ejb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb" Watch "ejb" New topic
Author

ejb

ashok rao darnasi
Greenhorn

Joined: May 25, 2007
Posts: 2
how to call ejb from a servlet
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10240
    
168

Your EJB would be bound to the JNDI tree by a specific name. You will have to do a lookup using the InitialContext object and pass the jndi name of the bean to the lookup method. The lookup is going to return you a EJB home object or a remote/local interface depending on which version of EJB you are using.

For EJB 2.x, the code would look like:


This is just a pseudo-code. You might have to lookup some examples online or in some books to understand what each of the above statements are meant to do. Note that for EJB3, this is going to be different. Infact, you dont even have to write code to do the lookup. You can rely on Dependency Injection.


[My Blog] [JavaRanch Journal]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ejb