Originally posted by Alok Srivastava:
Firstly if i am using BMP(bean managed persistence) i have to write actual sql queries.. as i need to do in a servlet... but in addition i have to make a remote, home and PKclass, deployment descriptors.. which is definetly an overhead.
Although there are overheads of creating more classes with EJB, it is still worth it.Reasons-You are seperating
serious business logic from Presentation.By
serious, I mean those processes, which are very much data/business-intensive in nature.
If you look at Servlets/JSP, it is nothing but a HTML rendering software.It cannot take the place of Enterprise Applications/Beans like Credit Validation, Credit Processing System, Financial Authorization System and other data-intensive processes.
The data processed by these EJB could be formated by the JavaBeans/Taglibs/Servlets/JSP's to do some minor processing (probably to format it in the manner required by the client!!) and present it to them.
Originally posted by Alok Srivastava:
As far as locking on databse access is concerned in case of different users accessing the same database, i think almost all of the rlational dtabse, like Oracle, sybase etc. provides this feature. so i don't need to bother about this whether i do my job thru' a servlet or EJB.
Would you like to take care of multiple clients accessing your records simultaneously?Would you like to provide Threading feature in your code (and thus hamper performance!!), when you have a technology in place which can do this for you.
Do you wish to code to cache the data in your web server, to take care of DIRTY READS,REPEATABLE READS and PHANTOM READS?Won't this increase your code?Also, will your focus not get diverted to handle these low-level services instead of concentrating on implementing the business requirement?
Originally posted by Alok Srivastava:
Now if am using a CMP(container managed persistence) how do i make join queries involving multiple tables... for that i will need a tool like toplink to handle that issue, whihc i definetly don't need in case of servlets.
Joining mutiple tables maynot be possible in J2EE reference implementation.But it you take any good Application Server, it provides this functionality.I know IBM WebSphere Application Server, which allows this.Also, Oracle has come out with an excellent technology called "Business Components for Java" which is based on the lines of EJB, which not only provides a feature for joining mutiple tables, but also provides validation for the records selected.I am sure there may be many more Application Servers available in the market, which provides better functionality.
If you consider doing this with servlets, how would you manage synchronization of data across distributed databases. You would need to use JTA (another J2EE technology) and two-phase commit to tackle this.Would you like to implement the Resource Managers and the Transaction Managers to manage the synchronization of data.Why not leave it to the expert - J2EE?
Originally posted by Alok Srivastava:
Futher more.. as far as interaction between beans from different JVM's are concerned, how do i do that.. without adding anything to my code..??? its impossible...what i need is an RMI.. which i can do even in case of servlets...
What about applications written in different languages say Java and C++?How are you going to make it talk by using servlets?You will need RMI-IIOP protocol.J2EE containers provides these services implicitly and are better suited to handle such calls.
Hope this give some justification on the use of EJB and servlets.I believe, they are complimenting technologies, not replacements of each other.
Hope this helps,
Sandeep
- Sun Certified Programmer for Java 2 Platform Scored 93 per cent
- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
- IBM Enterprise Connectivity with J2EE Scored 72 per cent
- Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
[This message has been edited by Desai Sandeep (edited May 15, 2001).]