In Jsp and Servlet, when traverse between Jsp page and Servlet, there are two ways:
1. using jsp:forward
2. using response.sendRedirect(url)
here is the summary of the each method:
jsp:forward
<jsp:forward page= “success.jsp”;
in this way, the request will be transftered down, all the attributes in the previous request can be accessed in the new page.
However, there is one problem that, the url of the new page won't be displayed in the IE address bar, user can not see the url address
response.sendRedirect(url)
in this way, there will be one new request created for the direction, in the new page, user can't access the attributes in the previous request, if you want to share any value in the request, redirection won't be the best way.
And what is more, the new url address will be displayed in the IE address bar.
However, since the url will be displayed in the IE address bar, so there is one new problem that: you must do some check for the case of error usage of the url page.
JSP与Servlet页面跳转
本文介绍了在JSP和Servlet中实现页面跳转的两种主要方式:使用<jsp:forward>标签和response.sendRedirect(url)方法。详细对比了这两种方式的特点,包括请求范围属性的传递情况、浏览器地址栏的变化等。

被折叠的 条评论
为什么被折叠?



