wood burning stoves
The moose likes EJB and other Java EE Technologies and the fly likes ejb v/s servlets 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 "ejb v/s servlets" Watch "ejb v/s servlets" New topic

ejb v/s servlets

saahil sinha
Ranch Hand

Joined: Apr 07, 2003
Posts: 68
What is the advantage of ejb over servlets
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
It's quite difficult to give a good answer to this, I think, because EJBs and Servlets are such different kind of beasts.
Enterprise JavaBeans is a component model (similar to CORBA's CCM or Microsoft's COM) and provides support for component based development, assembling an application out of components (that is, EJBs). These components (EJBs) can be developed to provide services (session beans), persistence (entity beans), asynchronous processing (message-driven beans) and all in between. Servlets on the other hand are more focused "components" -- they are only suitable for request/response processing (typically for HTTP requests but theoretically for any request/response protocol necessary).

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
Perhaps a better question would be:
Q: What are the advantages of using EJB's to implement an application's business logic vs using proprietary Java classes?
A: EJB's are too cumbersome in smaller, simpler applications (i.e. EJB's are over kill in some situations).
Proprietary Java classes have less overhead since they can live in the Web container along with the presentation layer (no RMI calls are involved). They are faster in smaller applications (>300 concurrent users) where memory management is not an issue.
EJB's can service requests from multiple applications. EJB's (and their container) eliminate the need to write transaction processes. The EJB container can re-use the same objects to service multiple requests. EJB's can exist on a seperate server from their client applications.

Please discuss....
I agree. Here's the link: http://aspose.com/file-tools
subject: ejb v/s servlets
It's not a secret anymore!