首页 > 其他分享 >Lab02-3

Lab02-3

时间:2023-04-15 22:33:23浏览次数:33  
标签:name request Lab02 cookie 跳转 password 两秒

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<%
request.setCharacterEncoding("utf-8");//解决中文乱码的问题
String name = request.getParameter("username");
String password = request.getParameter("password");
session.setAttribute("name", name);
Cookie cookie = new Cookie("name",name);
cookie.setMaxAge(300); //设置cookie有效期为30s
response.addCookie(cookie);
if(name.equals(password))
{%>
<h1>用户登录成功两秒后为您跳转</h1>
<%
response.setHeader("refresh", "2;url=index.jsp");
}
else{%>
<h1>用户登录失败两秒后跳转请重新登录</h1>
<% response.setHeader("refresh", "2;url=login.jsp");
}
%>
</body>
</html>

标签:name,request,Lab02,cookie,跳转,password,两秒
From: https://www.cnblogs.com/yingxq/p/17322114.html

相关文章

  • CS61A_lab02
    1defcycle(f1,f2,f3):2"""Returnsafunctionthatisitselfahigher-orderfunction.34>>>defadd1(x):5...returnx+16......