File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

Servlet or EJB design question for Online Store

Bob Wellerson

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

Joined: Feb 05, 2001
Posts: 17276

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.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Bob Wellerson

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.
I agree. Here's the link:
subject: Servlet or EJB design question for Online Store
It's not a secret anymore!