四种属性范围
pageContext
只在一个页面中保存属性,跳转之后无效。
request
在进行服务器跳转时候有效,客户端跳转无效,可以多次服务器跳转
session
服务端客户端跳转均有效
application
只要服务器不关,随处可用
<jsp:forward page="page.jsp"/> 服务端跳转
<a href="page.jsp">跳转页面</a> 客户端跳转
属性操作方法:
设置属性名和内容
1.pblic void setAttribute(String name,Object o)
获取属性名和内容
2.public Object getAttribute(String name)
删除属性名和内容
3.public void removeAttribute(String name)
Cookie的使用
Cookie c1 = new Cookie("name","soft1731");
response.addCookie("name");
获取Cookie
在获取页面中输入:
Cookie[] c=request.getCookies();
if(c.length>0)
{
for(int i=-;i<c.length;i++)
{
out.print(c[i].getName()+c[i].getValue());
}
}
注销Cookie
c1.setMaxAge(60); //可以存储60秒
response 刷新页面测试
response.setHeader("refresh","2");
One comment
Meeeeeeeeee