Solved

EJB - Struts - MVC

Posted on 2006-07-16
9
997 Views
Last Modified: 2013-11-24
Hi Guys,

I'm in the initial stages of learning EJBs and Struts.

My question is - When I say ....I'm using Struts in a Project it means i'm using MVC model-2. And in the same project can I use EJB's . If Yes, can you explain in terms of using Struts and EJBs combinely.


Thank You,
Jagadeesh
0
Comment
Question by:jagadeesh_motamarri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 16

Accepted Solution

by:
suprapto45 earned 125 total points
ID: 17119409
Hi,

If you would like to combine both EJB and Struts together, here is what we normally do.

Struts will only manage the flow of the application as well as doing all the validation to and from JSP. JSP interacts with Struts. Then Struts action will call the method in the session bean to do all the business logic. Normally, business logics are located in session bean and not in the Struts.

David
0
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 17119756
then EJB is your controller
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 125 total points
ID: 17120055
jagadeesh_motamarri,
> I'm using Struts in a Project it means i'm using MVC model-2. And in
> the same project can I use EJB's . If Yes, can you explain in terms of
> using Struts and EJBs combinely.

Yes you can use EJBs in the same project. JSPs via Struts will be there for the View (i.e. for displaying the data to the user), EJB and struts action classes will be the controller (i.e. will be loading the data from the database and will do the appropriate actions, e.g. calculate things etc) and the data in the database will be the Model. You will need to be calling EJBs from your JSP pages.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 4

Assisted Solution

by:Meritor
Meritor earned 125 total points
ID: 17122674
>Yes you can use EJBs in the same project. JSPs via Struts will be there for the View (i.e. for
>displaying the data to the user), EJB and struts action classes will be the controller (i.e. will
>be loading the data from the database and will do the appropriate actions, e.g. calculate
>things etc) and the data in the database will be the Model. You will need to be calling EJBs
>from your JSP pages.

You have suggested to make EJBs as Controller and call them through JSP that is not a good practice.
Generally, only business logic should be written in EJB.
Only Struts ActionServlets and struts-config.xml should only be the controller.
And your Action classes should call EJB which contains the core business Logic.
0
 
LVL 35

Expert Comment

by:girionis
ID: 17122729
Actually no. I have suggested to use EJBs *and* Struts actions as controller :)

But I will agree with you, it's not a good practice to call EJBs straight from JSP, although nothing prevents you of doing so.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 17129880
http://java.sun.com/blueprints/guidelines/designing_ enterprise_applications_2e/web-tier/web-tier5.html
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 125 total points
ID: 17129885
Oops :) java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question