Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet vs EJB  RSS feed

 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple query .I would like to know the why should we go for a combination of servlet plus EJB when we can achieve the same business logic using Servlet ?
Ravindra
 
George Brown
Ranch Hand
Posts: 919
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the EJB & J2EE forum because I think the subject is more related to enterprise design decisions than WebLogic Servers, and it should get a better response there.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your business processing is very simple, then you may not need EJB, but there are several things I think you should bear in mind.
1. EJB containers are very powerful and can help simplify a lot of problems. Container Managed Persistence, for example, can be very useful and save a lot of effort.
2. Servlets are realistically limited to providing a Web user interface. Many real-world problems also need some other sort of interface as well (command-line, graphical application, applet, connection from non-Java application etc.)
3. Putting business logic directly in servlets is always a bad idea. It's much better to build an application data model which your servlets access using a minimal API. This API often ends up looking a lot like an EJB API.
4. EJB is a fundamentally distributed design idiom which scales well if you need more horsepower for your applications. Such scalability usually has to be added and maintained manually in a pure servlet solution.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!