Request实例:
requestScope.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>requestScope.jsp</title>
</head>
<body>
<%
//设置request范围的俩个对象
request.setAttribute("name", "request范围的小明");
request.setAttribute("age", 21);
%>
<jsp:forward page="requestTarget.jsp"></jsp:forward>
</body>
</html>
requestTarget.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>requestTarget.jsp</title>
</head>
<body>
<%
//取值(取出值为object对象)
String name = (String)request.getAttribute("name");
int age = (Integer)request.getAttribute("age");
%>
name:<%=name %><br>
age:<%=age %>
</body>
</html>
运行结果:
分析request执行过程:
别的jsp页面访问不到,数据只在requestScope.jsp转向的页面requestTarget.jsp
能查到,且数据在requestTarget.jsp执行之后,就被删除了!