0
在我的jsp頁面我有註銷按鈕。當我點擊它時,我應該調用一個servlet幷包含session.invalidate()代碼或調用一個jsp幷包含此代碼,或者將代碼包含在每個jsp頁面中我有註銷按鈕的地方。在哪裏包括session.invalidate()代碼
logout.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
session.invalidate();
response.sendRedirect("index.html");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>logout</title>
<%
response.addHeader("Cache-Control", "no-cache,no-store,private,must-revalidate,max-stale=0,post-check=0,pre-check=0");
response.addHeader("Pragma", "no-cache");
response.addDateHeader ("Expires", 0);
%>
</head>
<body>
</body>
</html>
這取決於你。你想把它放在哪裏?沒有單一的答案。 – EJP