How JSP can talk to EJB?

Discussions

Web tier: servlets, JSP, Web frameworks: How JSP can talk to EJB?

  1. How JSP can talk to EJB? (4 messages)

    Hi,
    I'm in need to make some JSP's to talk to EJB's, can anyone help by exploring in detail?

    Thanks in advance
    Devendra

    Threaded Messages (4)

  2. How JSP can talk to EJB?[ Go to top ]

    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.

    Zhihong
  3. How JSP can talk to EJB?[ Go to top ]

    Devendra,
    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.

    Chris
  4. How JSP can talk to EJB?[ Go to top ]

    Hi,

    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!
  5. How JSP can talk to EJB?[ Go to top ]

    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";
      request.setAttribute("Account", account);

      //Process the template.
      RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher(template);
      requestDispatcher.forward(request, response);
    }

    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"); %>