Reputation: 79635
I'm using a Java Servlet to do some work (validate user login, update session values, etc.) and I want to redirect to an existing JSP page when I'm done. How do I do that?
Upvotes: 1
Views: 185
Reputation: 90447
Apart from using HttpServletResponse.sendRedirect()
, you can also set the http response header and status code to SC_MOVED_PERMANENTLY (301)
or SC_MOVED_TEMPORARILY (302)
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", "http://www.xxx.yyy/");
Upvotes: 0
Reputation: 939
also to sendRedirect
take a look at
request.getRequestDispatcher("/foo/foo.jsp").forward(request, response);
redirect is useful then you changed some information (e.g. made a post in the forum) so redirecting will prevent double posting.
Upvotes: 2