• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB used in J2EE

 
Armand Aquino
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When is it really necessary to use EJB's in J2EE applications? I write some in-house applications and only use JSP and Servlets.
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jsp and Servlet are particularly meant for developing Intranet based applications,Who can also use EJB for developing these applications.
If you want to develop a Robust,high performance,realiable applications,escp some mega projects like Logistics management,distributed ware hosue project,then EJB is the best suite for it. Because EJB is meant for developing component based architecture projecs.
Correct me if i'm wrong.
Rehgards
Balaji
Originally posted by Armand Aquino:
When is it really necessary to use EJB's in J2EE applications? I write some in-house applications and only use JSP and Servlets.

 
Allan Moster
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Balaji Loganathan:
Jsp and Servlet are particularly meant for developing Intranet based applications,Who can also use EJB for developing these applications.

I disagree! There are good uses for EJBs but there are many more projects for which Servlets and JSPs are more than sufficient.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Armand,
As with most programming related questions, the answer is a
resounding "that depends". I can tell you what you get with EJB,
but your requirements will determine whether EJB suits your
project.


The EJB container gives you transaction management and automatic
synchronization with the database. One of the ideas behind EJB
was to build components that perform your application's business
logic. Prior to EJB, many people performed their applications'
business logic using database triggers and stored procedures. The
people who put together the EJB architecture figured it was
better to perform business logic outside of the database -- in
the "middle tier" of n-tier client/server applications.




Since EJBs are outside of the database, you need to keep your
beans' states synchronized with the database -- something you
don't need to worry about with database triggers and stored
procedures.




Of-course this doesn't mean that you must either use EJBs or
database triggers. You can manage your own synchronization with
the database via JDBC if you want to use (for example) only
servlets and JSPs. As I said before, your project requirements
will probably dictate which architecture is the best to use.




Personally for me, I think EJBs should be used to perform
application business logic and I like the fact that the EJB
container manages transactions and data synchronization, but each
one of us is an individual (I'm not :-)


Good Luck,

Avi.


------------------
 
Prabhakar Goel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree partially to both allan and avi but though it is not a correct explanation to why should one go for actually using EJB's.
As for the Application Logic alone is the requirement it can be best handeled without any performance overhead with Servlets'. And i Strongly disagree that DBProcedures are much used for these purposes.
DBProcedures are used more for Client-Server kinda architecture where Application needs some kinda serverside business logic so that the Application Logic is minimum at Client End. This is very well handled by Procedures and Functions.
EJBs' in the recent past have been more of the hype kinda thing, and people going for their use without actually looking for the use wheather it is needed or not. This actually has resulted in Nothing but Performance Overhead and Highly Expensive Application Servers resulting in Job Cuts and Retrenchment.

------------------
enJoy Life with Technology ;-)
 
nishant_v
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Armand,
To answer your question, lets go back to the definition of EJBs. EJBs provide the architecture for component based enterprise applications. The stress is on making these components reusable, scalable & robust( for definition of these refer a good book on EJB like one by O'reily). The components should be as abstract as possible that is they should have some independent purpose & use. The transaction management( in simple terms synchronization with database), resource management forms the most difficult part of a server side development.
EJBs are deployed on an EJB server(like weblogic, websphere etc) which manages many features like transaction management, resource mangament. So we are saved from this hectic job if we use EJBs.
Now coming to application logic, it can be anywhere in servlets, EJBs or even in JSPs(though JSPs should be avoided for this use) but it depends on application requirements. But generally it is kept in a tier independent of your presentaion logic(JSP, html etc)& your databse.
Hope it helps.
Nishant
 
Reilly Morris
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Armand,
Check out "Enterprise JavaBeans" by Richard Monson-Haefel. It is a quick read and really illustrates the where and when of enterprise beans. You may also want to check out the book of the week "Professional Java Server Programming J2EE 1.3 Edition".
This book really covers all the bases, and you will likely find tools that you previously had never used!
Good luck with it!
Reilly
 
Bob Graffagnino
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Reilly Morris:

Check out "Enterprise JavaBeans" by Richard Monson-Haefel

I agree! Great book!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic