Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejb v/s servlets

 
saahil sinha
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the advantage of ejb over servlets
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Roger Graff
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic