Can we use EJB instead of Servlet as Controller in MVC architecture?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, June 6, 2002 09:30 PM

Hi,
I would like to know whether i can use an EJB instead of a Servlet as controller in MVC Architecture? will it provide any advantage in performance? Is it feasible in first place?
Please let me know

Re: Can we use EJB instead of Servlet as Controller in MVC architecture?

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.

About | Sitemap | Contact