response应用之传值:
一、客户端传值,
<%
// 跳转到其他页
response.sendRedirect("other.jsp?value=helloworld") ;
%>
此种传值只是页面之间的跳转,并且只有在本页面执行完成后才跳转。不能传递request.setAttribute()值。
二、服务器端传值,
<%
request.setAttribute("name","MLDN") ; // 设置request属性
%>
<jsp:forward page="other.jsp">
<jsp:param name="value" value="helloworld!!!"/>
</jsp:forward>
此种传值为服务器端传值,可以传递 request.setAttribute()值。在代码执行到跳转处,马上跳转。不会在执行下面语句了。
注意:在jdbc中关闭数据库操作必须在服务器端传值之前进行关闭,否则就会关不了。