safe.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
if (null == session.getAttribute("username")
|| "".equals(session.getAttribute("username"))) {
out.println("<script language='javascript'>alert('您的账户已经过期,请重新登录!');window.location.href='index.jsp';</script>");
return;
}
%>
main.jsp
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="safe.jsp"%>
<html>
<head>
<title>聊天室</title>