File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Using servlets with EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using servlets with EJB" Watch "Using servlets with EJB" New topic

Using servlets with EJB

Vipul Shinde

Joined: Sep 27, 2005
Posts: 6
Can any one tell me how can I use a EJB(Entity/Session) in a servelt.

If I want to use it in any of request methods i.e. doGet , doPost how should I work with it ?
Satish Chilukuri
Ranch Hand

Joined: Jun 23, 2005
Posts: 266

Can any one tell me how can I use a EJB(Entity/Session) in a servelt.

Have you worked with EJBs before? If yes then the answer would be to use them in the same way. (Look up the Home, create a bean etc..). If you haven't, the question is related to EJBs and not to servlets and you might consider going through some EJB tutorials and use the EJB forum if you have any doubts.
Keith Pitty
Ranch Hand

Joined: Sep 22, 2005
Posts: 32
Your servlet would need to act as a client to the EJB.

Briefly, it would need to use JNDI to locate the EJB, then use the EJB's Home interface to create an EJB bean instance before invoking methods on that instance via the EJB's Remote instance.
subject: Using servlets with EJB
It's not a secret anymore!