Posted By:
Nick_Maiorano
Posted On:
Thursday, June 27, 2002 07:29 PM
Hello,
You CAN use an EJB as a controller but you will still need a servlet to accept http requests (assuming your application is http-based). So this approach would only complicate things with no benefit. Furthermore, it will not perform as well as a controller written as a servlet. The great thing about servlets is that any session state (which can be saved inside a HttpSession object) is accessed as a regular java object residing in the same JVM. To accomplish this with an EJB architecture would require a stateless session bean acting as a controller and one stateful session bean for each user acting as the HttpSession. This will require RMI calls which will never match the performance of a local jvm method call.
If you need a 3-tier architecture, implement your MVC pattern as a servlet. Have this tier handle only presentation issues and do all your heavy processing in EJBs. This widely-used architecture will yield the best result.