File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes EJB used in J2EE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB used in J2EE" Watch "EJB used in J2EE" New topic
Author

EJB used in J2EE

Armand Aquino
Greenhorn

Joined: Jul 17, 2001
Posts: 22
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

Joined: Jul 13, 2001
Posts: 3150
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.


Spritle Software Blogs
Allan Moster
Ranch Hand

Joined: Sep 14, 2001
Posts: 153
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

Joined: Oct 11, 2000
Posts: 1135

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

Joined: Nov 21, 2001
Posts: 5
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 ;-)


pirbhu<BR>***********************************<BR>enJoy Life with Technology<BR>***********************************
nishant_v
Greenhorn

Joined: Oct 16, 2001
Posts: 3
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

Joined: Sep 11, 2001
Posts: 44
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


<b>Reilly</b> <br /><i>SCJP,J2EE,OOAD,iNet+,A+,CIW,<br />MCP,--</i>
Bob Graffagnino
Ranch Hand

Joined: May 30, 2001
Posts: 81
Originally posted by Reilly Morris:

Check out "Enterprise JavaBeans" by Richard Monson-Haefel

I agree! Great book!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB used in J2EE