<%@ 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>
<form action="/zzz/login.jsp" method="post">
<input type="text" name="name">
<input type="text" name="pwd">
<button>提交</button>
</form>
</body>
</html>
<%@ 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");
session.setMaxInactiveInterval(10);
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
if(name==null ||pwd==null){
name=(String)session.getAttribute("name");
pwd=(String)session.getAttribute("pwd");
}
if("王二".equals(name)&&"123456".equals(pwd)){
out.print("登录成功");
session.setAttribute("name", name);
session.setAttribute("pwd", pwd);
}else{
response.getWriter().print("登陆失败");
response.sendRedirect("/zzz/test.jsp");
}
%>
</body>
</html>