I have an issue with a JSP/Servlet set-up and what's getting displayed in the browser URL. page1.jsp submits to the servlet by a form with an action of "SAVE.do". The servlet wants to pass a success message back to page1.jsp on the save. I do this by placing the message in the request using the
request.setAttribute("message", "Save Successful");
I then call
request.getRequestDispatcher("page1.jsp").forward(req,resp);
However, the browser will display the URL of http://localhost:8080/SAVE.do instead of http://localhost:8080/page1.jsp
When I change the forward to a redirect using
response.sendRedirect("page1.jsp");
Then the attribute is lost.
I guess I'm looking for the right way to do this, so that I can get the attribute back when page1.jsp loads again, WITH the right URL displaying in the browser.