Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

EJB - Struts - MVC

Posted on 2006-07-16
9
Medium Priority
?
999 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
9 Comments
 
LVL 16

Accepted Solution

by:
suprapto45 earned 500 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 500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Assisted Solution

by:Meritor
Meritor earned 500 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 500 total points
ID: 17129885
Oops :) java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

916 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