This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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 :-)
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>***********************************
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
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