注销.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
session.invalidate();
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location","login.jsp");
%>
检查登录.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
if (session.getAttribute("UserName") != null && session.getAttribute("IPAddr") != null) {
} else{
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location","login.jsp");
}
%>
HTML 索引.php
<body>
<jsp:include page="checklogin.jsp" />
<div class="Maindiv">
<div id="Header">
<jsp:include page="Header.jsp" />
</div>
</div>
</body>
页眉.jsp
<table>
<tr>
<td align="left" valign="top" style="padding-right: 5px;">
<span class="lblDarkGray10">Welcome, <strong><%=(String)session.getAttribute("UserName") %></strong></span>
</td>
<td align="right" valign="top" style="padding-left:5px; border-left:solid 1px lightgray;">
<a href="logout.jsp" class="lnkDarkGray10">Logout</a>
</td>
</tr>
<tr>
<td colspan="2" align="right" valign="top">
<span class="lblDarkGray10"><%=(String)session.getAttribute("IPAddr")%></span>
</td>
</tr>
</table>
页面重定向 logout.jsp-working checklogin.jsp-not working
如果用户直接访问 index.jsp 那么它应该被重定向到 login.jsp