Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

EJB - Struts - MVC

Posted on 2006-07-16
9
Medium Priority
?
998 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 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

722 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