aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Calling a Ejb3.0 from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Calling a Ejb3.0 from a servlet" Watch "Calling a Ejb3.0 from a servlet" New topic
Author

Calling a Ejb3.0 from a servlet

Padma Priya
Ranch Hand

Joined: Feb 01, 2007
Posts: 113
Hi all,

Is it possible to call a sateless or stateful ejbb3.0 session bean from a servlet. If it possible could anyone please point me to a tutorial on this.

With Regards
Deepthi
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Yes. This shows how to do it, but more application servers also come with example code.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Paul's tutorial is for EJB2.x You'll find an example of using a stateless session bean from a servlet in the Java EE 6 Tutorial.


[My Blog]
All roads lead to JavaRanch
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Doh!
Padma Priya
Ranch Hand

Joined: Feb 01, 2007
Posts: 113
I have another doubt. If a request is sent to a servlet and this request is sent in a new thread. The servlet in turn calls another Ejb. So will the call to the Ejb take place in the same thread or another thread will be started.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The answer is: perhaps, but probably not. You need to think "does it matter"? One of the reasons you use EJB containers is to delegate the threading behaviour to the container itself. If you are doing something that requires you use the same thread you are probably doing somthing wrong. Why do you need to use the same thread?
Padma Priya
Ranch Hand

Joined: Feb 01, 2007
Posts: 113
Hi Paul,

Thanks for the reply. It was actually an interview question and i answered by saying that the ejb container takes care of creating threads for Ejbs. Didn't know if i was right or wrong.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling a Ejb3.0 from a servlet