Title: RE: Strut and EJB/J2EE

Hi Chuong,

J2EE covers EJB, JSP, Servlet, XML and other technologies, so a Struts application *is* a J2EE application (see http://java.sun.com/j2ee/overview.html for details).

What Struts provides is a MVC framework for writing Servlet/JSP applications.  These applications typically respond to requests via HTTP (i.e. a POST of data submitted in a HTML form), perform some business logic, and respond with a HTTP reply (i.e. a HTML page with some results).  Of course there are some very exotic variations on this theme!

Struts helps to build the request/response processing (via. the Struts Controller, and the Action and Form classes you implement) and the presentation (via. the JSP pages you implement using the Struts tags).

So where does EJB fit in?
For your question, the important thing is that you understand that the Stuts Action class you implement is where you implement your application behavior.

But you don't want to go writing your application logic right into the Action class do you!  You want to use sound OO principals right?

 


EJB comprises a bunch of technologies that can basically be described as a way to write business components (EJB's) in a standard way, that can be hosted in an EJB Container.  You write the EJB's, and someone else (a 3rd party vendor) writes the container.  The Container takes care of a lot of things, including: object lifecycle, resource pooling, and transactions.  That leaves just the "business logic" for you to worry about in your EJBs.

In a Struts application, you'd normally use services provided by your EJB's to implement your Struts Actions.  You could use an intermediate API to hide some of the complexities of discovering and accessing the EJB.

So now you have two software tiers working together.  You have your "web tier" (implemented with Struts), taking care of user interactions, managing workflow, generating persentation, and maybe handling some conversational state.  And you have your "business logic tier" (implemented in EJB) handling all of the business logic, transactions, etc.

You are now in J2EE nirvana...  ;-)

One final point, don't confuse the technology/implementations (servlet, JSP, EJB) as *being* the multi-tiered architecture.  J2EE is just an implementation of that architecture (IMHO a pretty darn good one too).  You can do all of this stuff without JSP, EJB, etc... just ask Bill Gates ;-)

Cheers,
Matt.

p.s. for more info, I suggest you start here http://java.sun.com/j2ee



-----Original Message-----
From: Chuong Huynh [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 25, 2001 13:09
To: Strut user List (E-mail)
Subject: Strut and EJB/J2EE


Hi all,

Sorry for naive question.

I'm new to Struts - just construct some simple examples by myself...

It seems to me that applications that use Struts are web-centric. I wonder
where EJB comes into play? And is it easy to migrate Struts apps to J2EE
applications...? Is Struts (alone) suitable for large scale applications,
without being a J2EE app?

Thanks,
- Chuong

=============================
 HUYNH, N. CHUONG
 TMA Software Solutions, Vietnam
 Tel: (84-8) 990 3848 - Ext: 5272
 Email: [EMAIL PROTECTED]
=============================

Reply via email to