I have a servlet in which I use- String name = request.getParameter("name"); String bdate = request.getParameter("bdate"); I would like to send this information to a JSP page- Welcome.jsp which displays the name and bdate. What are the lines of code I would use in my servlet to send this information to the JSP? How should I retrieve the information in the JSP in order to display it?
You can use RequestDispatcher rd = req.getRequestDispatcher("<Your JSP file>"); rd.forward(req, res); In your JSP page, the request paramters from the servlet will be available, and can be retrieved by calling getParameter on the implicit "request" object. Instead of using the request object to get the RequestDispatcher in the servlet, you can also use the ServletContext object which defines the same method to retrieve the request dispatcher.
Joined: Jan 19, 2004
But what do I do to set the name and bdate to the response object?