This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet or EJB design question for Online Store Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet or EJB design question for Online Store" Watch "Servlet or EJB design question for Online Store" New topic
Author

Servlet or EJB design question for Online Store

Bob Wellerson
Greenhorn

Joined: Aug 24, 2004
Posts: 5
I'm sure this question gets asked all the time, so please bear with me.

I am creating an online store for our company. As part of the design, I wanted to seperate the admin/back-office functions into a seperate webapp. The admin webapp will be located on our local company intranet. My question is about how to best design this in terms or servlets/ejb. Since both the storefront and the admin apps will share many of the same functions, if I create seperate webapps, I will be copying a lot of the same code into both apps. I have never used EJBs before, but it seems like if I put these shared functions into EJBs, I could then just call these functions from both my storefront and admin apps without having to copy any code?

Using this logic, it seems like EJBs are the only way to go to share code? Is that correct? Has anyone worked on a similar project that can offer any advice?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Bob, it all depends on how you code your application, or better yet, how you design your application. Frameworks like Struts and JSF are designed to seperate presentation from business logic and data access from both. For data access, I highly recommend using Hibernate, an Object Relational Mapping framework, that is highly decoupled from your business logic. By using techniques like this you can better create reuse in the business logic and data access sections of your code.

What this means is that EJB isn't the only way to go, actually i would say it is probably the more complicated way to go.

Another framework to look into that is less complicated than EJBs is the Spring framework/container, this way you can use plain old Java objects instead of EJBs and still get the benefits of an App Server for transactions, security, etc. And you only need to add what you need and not any more.

Good Luck and I hope this has helped a bit.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Bob Wellerson
Greenhorn

Joined: Aug 24, 2004
Posts: 5
Currently I am planning on using WebWork/Velocity/Hibernate in the app. I am just concerned about creating a method, then having to copy it to both my storefront app and admin app. This leaves open the chance of human error by not copying the same version of the method to both apps. If both apps could pull the method from a central location, everything seems to be solved.
 
Consider Paul's rocket mass heater.
 
subject: Servlet or EJB design question for Online Store
 
Similar Threads
Properties vs. Preferences
Is Eclipse really this hard? And how did it get so popular?
Parsing attributes across webapps
Cross Context sharing of Objects
Sharing Objects between Webapps