I'm in need to make some JSP's to talk to EJB's, can anyone help by exploring in detail?
Thanks in advance
Hi, there, check out Sun'2 J2EE document, Java 2
Exterprise Edition Developer Guide. There is one
JSP-EJB example in Chapter 7. Hope that will help.
Just make a java bean ( a facade to the EJB ) that will lookup the home via JNDI and then create the EJB. Just use this bean in the JSP to access your EJB.
How do you pass the reference of the EJB object to another JSP page? What is considered good practice? Would you store the home object in a session variable?
Thanks in advance!
One way to pass the reference is (using an example of an account object in a servlet):
if (account != null)
template = "/jsp/Member/Account.jsp";
//Process the template.
RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher(template);
Then reference the account object in the jsp file:
<%@ page import = "java.lang.String,java.text.*,java.util.*,com.path.Account" %>
<% Account account = (Account) request.getAttribute("Account"); %>