This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

With EJB why use Servlets.

 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen models of multi tiered Applications which use both servlets and EJBs. The way I see it, JSP represents the view, and servlets used to represent the business logic and link to the resources. With EJBs managing the business logic and EJB containers managing the resources, do we need the servlets.
Cheers for any help.
Tony
 
Leena Diwan
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
many systems use JSP-Servlet_Appserver combination so it is quite obvious to get confused
For a even more modular system, we can have a JSP-Servlet-EJB-AppServer architecture.
Servlets act as pure extensions of the web server.. handle the requests, delegates calls to EJBs , "locating" them and then proceeding.
EJBs contain all the pure business logic.
Does it help ?
Thanks for your cheers !
Leena
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess then you have to take a more finely defined understanding of business logic - Servlets are more performant than EJBs as well as lighter weight. Your servlets could include the application logic, while the EJBs would then become pure business logic, so, for a poor example perhaps:
JSPs show you balance
Servlets allow you to apply for an overdraft
EJB decides whether you can have one
JSP shows the result of the request.
I am not sure how sound an idea it is to be using EJBs from inside a JSP...
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a more detailed explanation of typical web application architectures, check out this chapter from Professional Java Servlets 2.3 to see where Servlets, JSPs and EJBs fit into the picture.
Hope that helps
Simon
 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the helpful replies, I will read up on that chapter.
Cheers Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic