This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb" Watch "ejb" New topic


ashok rao darnasi

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

Joined: Jul 20, 2005
Posts: 10441

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]
I agree. Here's the link:
subject: ejb
It's not a secret anymore!