File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes MVC, Struts, EJB - please explain Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "MVC, Struts, EJB - please explain" Watch "MVC, Struts, EJB - please explain" New topic
Author

MVC, Struts, EJB - please explain

Raj Bhandari
Ranch Hand

Joined: Oct 19, 2005
Posts: 97
Hi,

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,

Raj
Venkatraman Kandaswamy
Ranch Hand

Joined: Jul 07, 2004
Posts: 120
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.

Good luck !!


--Venkatraman<br />SCJP 1.4<br /><a href="http://kvrlogs.blogspot.com" target="_blank" rel="nofollow">blog</a>
Raj Bhandari
Ranch Hand

Joined: Oct 19, 2005
Posts: 97
Hi Venkatraman,

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

Raj
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61217
    
  66

Moved to the Struts forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MVC, Struts, EJB - please explain