I am fowarding the user from a servlet to a JSP page using getServletContext().getRequestDispatcher(refURL).forward(request, response); and when I do this, the URL in the address bar still shows the Servlet URL and not the JSP url. I know the foward is working correctly, but I just don't know why the URL isn't updating in the address bar. Thanks.
That's the intended behavior. When you forward the request using the dispatcher (a completely server-side operation), you are remaining within the context of the same request which was initiated by the URL seen in the address bar. The browser has no knowledge that you are forwarding things around on the server, and so the address remains unchanged. This is quite different from a redirect which asks the browser to initiate the new request. In this case, the browser is completely aware of what is going on and updates the address field accordingly. hth, bear
So I should be doing a response.sendRedirect() instead, right? Because I don't care about the request,response at this point. I just need to get back to the referring page. [ September 18, 2003: Message edited by: Gregg Bolinger ]
Right, if you want your JSP to display in a different request than the servlet, use a redirect. If you want the JSP to execute in the same request (done very often in Model 2 since the servlet does the processing and sets data on the request for the JSP to display), use a forward. hth, bear