如何清除jsp页面缓存、cookie、session?
1个回答
展开全部
一、清除页面缓存
在jsp页里:<%response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
response.flushBuffer();%
在html页里:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"
<META HTTP-EQUIV="Expires" CONTENT="0"
二、清除cookie<%Cookie killMyCookie = new Cookie("mycookie", null);
killMyCookie.setMaxAge(0);
killMyCookie.setPath("/");
response.addCookie(killMyCookie);%三、清除session
页面载入时清除session:
<%@ page language="java" %<%session.invalidate();%页面关闭时清除session
在jsp页里:<%response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
response.flushBuffer();%
在html页里:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"
<META HTTP-EQUIV="Expires" CONTENT="0"
二、清除cookie<%Cookie killMyCookie = new Cookie("mycookie", null);
killMyCookie.setMaxAge(0);
killMyCookie.setPath("/");
response.addCookie(killMyCookie);%三、清除session
页面载入时清除session:
<%@ page language="java" %<%session.invalidate();%页面关闭时清除session
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询