This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm not sure if this is the right forum, but I'd like to know your advice. I've cleared SCJP with 90% and currently work on j2ee and its mostly been jsp, servlets work. So far, I've learnt to avoid putting business logic in either of these. I try to follow basic MVC architecture that I've read in 1st-2 chapters HFSJ book i.e to use JSP as view, Servlet as controller and put most of the logic in a separate class (model). All I do is create object of the model class in the Servlet and call its methods to do things for me and then forward results to JSP. This works fine, but now I wonder then what is Struts and EJB ? Are they not MVC architecture ? Could someone please tell me how is Struts different from EJB and what purpose both solve ? The way I'm doing as explained above is that not correct then ? What books/articles should I read. Any advice is highly appreciated. Tks,
Originally posted by Raj Bhandari: I wonder then what is Struts and EJB ? Are they not MVC architecture ? Could someone please tell me how is Struts different from EJB and what purpose both solve ? What books/articles should I read.
Struts and EJBs are two different beasts. Struts is a framework that implements MVC architecture. So you are right in that aspect. The framework gives you hooks which you plug your code into and your application turns into this MVC thingy.
EJB is a specification written by Sun which 2 groups of people should satisfy. First group is the people who write containers ( IBM, Weblogic, JBoss, Oracle ) and the second group are the poor developers. Now if you write your code according to EJB specs you get lot of special features for free ( the container writers ensure that ) - like - Transaction, Security, Scaling, Caching, and so many things which the developers need not write code - as the wise say - reinventing the wheel. So the developers just worry about the business logic and leave the other bigger worries to the container developers.
And for you to ponder - you can have a struts application with EJB !! Also find out about Session Beans, Entity Beans and Message Driven Beans - Great concepts.
Tks for the overview. I also visited your blog which has 2 articles on Struts. Its really helpful. I'm getting the impression that currently I use a plain java class to handle the business logic and struts is using a servlet (other than the controller) to do the business instead of using plain java class. EJB seems like a different beast at this moment and with time hopefully I'll get a better understanding. Tks