开发者

How many ways are there on Redirect to next page in jsp?

开发者 https://www.devze.com 2023-02-05 19:28 出处:网络
in how many way can we redirect to next jsp page from one page to another page apart from following two ways,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消