Summary on 20080617: using forward or redirection in jsp and servlet

本文介绍了在JSP和Servlet中实现页面跳转的两种主要方式:使用<jsp:forward>标签和response.sendRedirect(url)方法。详细对比了这两种方式的特点,包括请求范围属性的传递情况、浏览器地址栏的变化等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值