File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How to call EJB (Session beans) using Struts framework? 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 "How to call EJB (Session beans) using Struts framework?" Watch "How to call EJB (Session beans) using Struts framework?" New topic
Author

How to call EJB (Session beans) using Struts framework?

Meghna Bhardwaj
Ranch Hand

Joined: Jun 08, 2007
Posts: 109
HI All,

I am trying to find out what is the best way to call business logic components (eg. session beans) using the Struts framework.

I have read that the Action class can be used along with a Business Delegate pattern and Session facade to accomplish this. Is this the only way to do this, are there any other options? I am interested to know how exactly is it done in big enterprise level applications?

If there are any tutorial links or sample code I would be extremely grateful! Will really appreciate any thoughts.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30910
    
158

Meghna,
There are other options. You can do anything you want. The one you described is a common pattern with a clean design.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Code, I love code.

Here is some code for calling remote stateful (SFSB)and stateless session EJBs (SFSB). In these examples, I just do it from a Servlet. There's lots of drawbacks to that, not to mention the tight coupling of the Servlet to the EJB. Your analogy would be tight coupling from the Struts action class to the EJB. Same difference.

The more layers, and more design patterns you use, typically decouples your control layer from your logic layer. That's typcially a good thing.

For some EJB development tutorials, including the multimedia tutorial that shows you how to create the EJBs used in the code below (I copied and pased the code from the tutorial), then check out the following link:

Free Multimedia Tutorials on J2EE Develoment with EJBs, Servlets, POJOs and JavaBeans (CBTs)




-Cameron McKenzie
Meghna Bhardwaj
Ranch Hand

Joined: Jun 08, 2007
Posts: 109
Thank you Cameron. Great example, appreciate it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call EJB (Session beans) using Struts framework?