What is the difference between EJB and JavaBeans ?

October 28, 2007 · Filed Under Java EE Interview Questions, Placement Questions 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

JavaBeans are reusable components of applications. EJB provides remote access to enterprise application logic. EJB can be used only on application server while JavaBeans are standard java elements.

JavaBeans

Basically used to CUSTOMIZE EXISTING OBJECTS. i.e. You can create USER OBJECTS, which are based on existing objects.
Ex.: A default button operates as a Single-State Switch. i.e. when you press a button on a web page, it doesn’t remain pressed. Infact, it immediately bounces back to its OFF state like a Door-Bell. Now, let’s say, you need a button, which should have 2 stable states, like the typical Electrical Light Switch. So, in this case, what you can do is, take an existing button (having 1 stable state) and CUSTOMIZE it so that it has 2 stable states. This is possible using JavaBeans.

Enterprise Java Beans (EJB)

EJB is a completely different concept than the one mentioned above. It is NOT used to customize existing objects. Instead they are basically used to STANDARDIZE the way, in which
business logic is written.

Ex.: We can write our business logic as well as the GUI logic, inside Servlets/Applets/StandAlone applications itself. But this way,there will be no clear distinction between the Code that is responsible for the GUI and the actual Business logic code, because everything is written inside the same class file. So, to COMPONENTIZE we write business logic in seperate class files than the GUI logic, thereby making a clear distinction
between the reponsibilities.

Related Articles


Get Latest JobsAdda.com Jobs, news & updates  via Email