欢迎页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>欢迎页面</title>
</head>
<body>
<h2>欢迎页面</h2>
<br>
<%
//判断是否存在用户名cookie,存在就输出,不存在跳转到登录页面
Cookie cookie = null;
Cookie[] cookies = null;
cookies = request.getCookies();
cookie = getCookieByName(cookies, "username");
if (cookie != null) {
out.print("登陆成功! welcome!" + cookie.getValue()
+ "!---cookie方式");
} else if (session.getAttribute("username") != null) {
out.print("登陆成功! Welcome!" + session.getAttribute("username")
+ "!---session方式");
} else {
response.sendRedirect("login.jsp");
}
%>
<%!//