Solved

EJB - Struts - MVC

Posted on 2006-07-16
9
990 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 125 total points
Comment Utility
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
Comment Utility
then EJB is your controller
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 125 total points
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 4

Assisted Solution

by:Meritor
Meritor earned 125 total points
Comment Utility
>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
Comment Utility
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:mayankeagle
Comment Utility
http://java.sun.com/blueprints/guidelines/designing_ enterprise_applications_2e/web-tier/web-tier5.html
0
 
LVL 30

Assisted Solution

by:mayankeagle
mayankeagle earned 125 total points
Comment Utility
Oops :) java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
strCount chalenge 3 50
java set up 1 46
Problem to start Neon 20 49
JUnit 4 @Before and @BeforeClass differences 3 19
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now