It's not a secret anymore!*
The moose likes Servlets and the fly likes With EJB why use Servlets. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "With EJB why use Servlets." Watch "With EJB why use Servlets." New topic
Author

With EJB why use Servlets.

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
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

Joined: Jun 18, 2001
Posts: 351
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


[SCJP2, SCWCD1.3, SCBCD]
chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
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...


chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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

Joined: Jun 29, 2002
Posts: 579
Thank you for the helpful replies, I will read up on that chapter.
Cheers Tony
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: With EJB why use Servlets.