Hi,
I wanted my servlet to use the services of EJB component in getting some information and redirect it to the a JSP page to show it, How can I do this? Can anybody help me on this.
Thanks
Abeers
-
Servlets - JSP - EJB (3 messages)
- Posted by: Anil Beeravolu
- Posted on: August 29 2000 01:21 EDT
Threaded Messages (3)
- Servlets - JSP - EJB by Peter Shillan on August 29 2000 08:00 EDT
- Servlets - JSP - EJB by Peter Shillan on August 29 2000 08:06 EDT
- Servlets - JSP - EJB by Kapil Israni on August 31 2000 08:31 EDT
-
Servlets - JSP - EJB[ Go to top ]
- Posted by: Peter Shillan
- Posted on: August 29 2000 08:00 EDT
- in response to Anil Beeravolu
I assume you know how to find your EJB and get a reference to it? Good :-)
One way of doing this would be to create the naming context, get the EJB home then EJB reference, gather your information and put it into a JSP bean. You can do this in your doPost/doGet. This bean can be added to the session using:
HttpSession session = request.getSession();
session.setAttribute( myJSPBean );
In the JSP, use the <usebean> tag to specify a JSP bean at session scope which *must* be created already. Use this bean to display your information.
Peter. -
Servlets - JSP - EJB[ Go to top ]
- Posted by: Peter Shillan
- Posted on: August 29 2000 08:06 EDT
- in response to Peter Shillan
Something I forgot to mention is that to redirect, the servlet only has to call
response.sendRedirect( <your URL> );
and make sure it doesn't write to the response object afterwards. <your URL> will be the JSP which contains the <usebean> tag. -
Servlets - JSP - EJB[ Go to top ]
- Posted by: Kapil Israni
- Posted on: August 31 2000 08:31 EDT
- in response to Anil Beeravolu
to redirect to JSP page from ur servlet, u shud always use
RequestDispatcher dispatcher = getServletContext ().getRequestDispatcher(jspPageUrl);
dispatcher.forward(request, response);
and bout sending some piece of data fetched from bean method call to JSP page,
request.setAttribute("DATA", bean.data());
now u can use the request object in jsp page-
request.getAttribute("DATA");