wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Java Bean vs EJB 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 » EJB and other Java EE Technologies
Bookmark "Java Bean vs EJB" Watch "Java Bean vs EJB" New topic

Java Bean vs EJB

Aaron Roberts
Ranch Hand

Joined: Sep 10, 2002
Posts: 174
IIRC an EJB is an Enhanced Java Bean? In a nutshell, how does an EJB differ from a Java Bean?
A bean is pretty much just the getters and setters for fields off of an html form correct?
Does an EJB contain more program logic?
Aaron R>
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Strictly a JavaBean is a component designed for GUI programming. The term predates J2EE and specifies a self-contained software component, i.e. it will contain both properties and methods to publish changes in those properties (typically event driven and using introspection). The term has been co-opted in the J2EE world to basically mean a class which represents some data - it has accessor and mutator methods which would be used by (for example) JSP to disply the data in a web application. So you are right, it is pretty much "the getters and setters for fields off of an html form"
An Enterprise Java Bean is a completely different type of component. The key difference with any other Java class is it they are designed to work in a distributed, multi-user environment. EJBs can only exist within an EJB container (Weblogic, Websphere, JBoss etc.), and they provide certain behaviour that is usually required for this type of software component: transaction management, (implicit) thread management, declaritive security, clustering etc.
Have a look at the J2EE tutorial on Sun's site for an introduction.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Aaron Roberts
Ranch Hand

Joined: Sep 10, 2002
Posts: 174
Thanks for the info! That was exactly what I needed to know. Know I don't have to worry that my beans are the wrong type of bean just because I didn't understand the terminology.
Aaron R>
I agree. Here's the link: http://aspose.com/file-tools
subject: Java Bean vs EJB
Similar Threads
What Is The Difference Between JavaBeans and EJB?
Worthness of Reading HF EJB Book ,for EJB3.0
Appeared SCBCD5.0 Beta on Saturday
is java bean a distributable component like EJB?
use Bean tag