in how many way can we redirect to next jsp page from one page to another page apart from following two ways,
RequestDispatcher rd = request.getRequestDispatcher("MyPage.jsp");
rd.forward(request, response);
and
response.sendRedirect("MyPage.jsp");
when i go to second page(MyPage.jsp) it has to load as f开发者_运维技巧resh page from server side,
RequestDispatcher and sendRedirect are different things. If you want to
load as fresh page from server side,
then RequestDispatcher won't work. The client (browser) still thinks the content comes from the original request.
Take from JGuru:
http://www.jguru.com/faq/view.jsp?EID=376&page=2
You can also physically alter the Location HTTP header attribute, as shown below:
<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
String newLocn = "/newpath/index.html";
response.setHeader("Location",newLocn);
%>
Redirect has two types permanent and temporary redirect.
精彩评论