wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes how to implement business logic in a java bean/ejb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to implement business logic in a java bean/ejb" Watch "how to implement business logic in a java bean/ejb" New topic
Author

how to implement business logic in a java bean/ejb

Nidhi Singhal
Ranch Hand

Joined: Sep 19, 2004
Posts: 89

hi
i have to seperate the business logic from my servlet/jsp using beans/ejb.
please give me some example of how to go about it..
thanks..
nidhi
Anurag Mishra
Ranch Hand

Joined: Sep 27, 2001
Posts: 133
Hi,
Just pass the method parameters from your jsp's or servlets to your ejb's where all your business logic is residing.

For eg:-

<pre>
<%@ page import="javax.naming.*"%>
<%
Context ctx=new InitialContext();
BeanHome ejb = (BeanHome) ctx.lookup("Bean");
// additional code here
%>
</pre>

Call your ejb's through look-up and pass the required parameters
for further processing of the request.

Regards

Anurag
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
Hi,

you can put the business logic in session beans.

Here is the tutorial giving example for that-
http://www.tusc.com.au/tutorial/html/index.html
Nidhi Singhal
Ranch Hand

Joined: Sep 19, 2004
Posts: 89

thanx alot Anu, Damanjeet for the help.

the tutorial seems to be really good.

nidhi
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Hi Nidhi,
How much comfortable are you with these technologies?
If you have reasonable amount of knowledge of JSP/ Servlet and EJBs than i will recommend you to go for MVC architectute using struts framework.
MVC (Model View Controller) architecture seperates Business logic completely from the presenation layer, something what you are looking for.


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Vijay Sharma
Ranch Hand

Joined: Feb 02, 2005
Posts: 32
Hi Nidhi,
This is John,I have a very good solution of ur problem.U want to separate the business logic with the presentation logic.Just do one thing Make one Ejb,Any (Entity bean,Session Bean).So,in all we made one component.Then Ur presentation parts come to picture.Now just built JSP pages for presentation purpose,and any extra data connection if needed.And Use Servlet wherever necessary,like if u wanna to check for login,there for internal logic u can use servlet.It's very easy to do.Once u got familiar with the beans part.


Vijay Sharma
Vijay Sharma
Ranch Hand

Joined: Feb 02, 2005
Posts: 32
Now when u want to use the component.
1.Create the object for initial Context.
2.Lookup.
3.Create Remote Interface Object to access the business menthod.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to implement business logic in a java bean/ejb
 
Similar Threads
Creating EJB using a framework
Data Access Object Pattern
Difference between business delegate and session facede?
Ejb and JMS Interaction
Why struts when there is EJB?