• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

difference b/w EJB ,servlets

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
If anyone can able to explain me the major differences in EJB and Servlets with an example.I know servlets and bit of EJB as well.So i`m really confused where & when to use EJB.
Explanation with examples will be much more appreciated.
cheers
Genji.B.Srinivasulu
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJB is server side componet contains bussiness logic only.It clearly separates bussiness logic from system level programming like transaction, security, persistance etc.

Servlets is based on request-response paradigam.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you better download the J2EE Tutorial from java.sun.com. Or you may refer to any other book or tutorial. there is no other better substitute.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Difference between Servlets and EJB:
1. Servlets Run on web container of the Web Application server
where as EJB runs on EJB Container either provided explicitly
(JBoss, Blazix) which needs to be configured with a web server
, or the web application server (costly ones) comes with
integrated EJB containers (Sun Java Application Server, Websphere,
BEAWeblLogic)

2.It is the EJB container which maintains EJB's peristence,
transactions and pools. But for Servlets there is no such thing
like this. To maintain session persistense using Servlets, the
programmer/developer has to take care of it usiing session
attributes and also has to keep an eye on thread safety of the
servlets.

3.A servlet can service only web requests. Ofcourse it can also be
called from sockets (tedious programming and security hole) but
EJB's can be tied up to client server objects also through RMI-IIOP
/JNDI.

4. EJBs (Bean Managed Persistense & Container Managed Persistense,
I mean not session beans) has finder methods, Servlets do not
have such.

5. A CMP bean represents an entity at database level, not servlets.

I hope I am being able to answer these at a very theoritical level.
But honestly speaking these cannot be exemplified programatically. Coding
for servlet and EJB if you want to know - download SUN JDK J2EE and play
with the samples.

Regards,

Caesar
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic