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.
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.
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.
to redirect to JSP page from ur servlet, u shud always use
RequestDispatcher dispatcher = getServletContext ().getRequestDispatcher(jspPageUrl);
and bout sending some piece of data fetched from bean method call to JSP page,
now u can use the request object in jsp page-