1.用户登录界面
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1> 用户登陆界面</h1>
<form action="do_login.jsp" method="post" name="登陆界面">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" > </td>
</tr>
<tr>
<td>密码:</td>
<td> <input type="password" name="password"></td>
</tr>
<tr>
<td><input type="submit" value="登陆"></td>
</tr>
</table>
2.登录信息处理界面
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户请求处理页面</title>
</head>
<body>
<%
String name="";
String word="";
name=request.getParameter("username");
word=request.getParameter("password");
request.setCharacterEncoding("utf-8");
%>
<%
if("admin".equals(name)&& "admin".equals(word)){
session.setAttribute("loginusername", name);
//response.sendRedirect("success_login.jsp");
request.getRequestDispatcher("success_login.jsp").forward(request, response);
}else{
response.sendRedirect("fail_login.jsp");
}
%>
3.登录成功提示页面
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>登陆成功</h1>
<%
String loginame="";
if(session.getAttribute("loginusername")!=null){
loginame=session.getAttribute("loginusername").toString();
}
%>
用户名为:<%= loginame %>
</body>
</html>
4.登录失败界面
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>登陆失败</h1>
<a href="login.jsp">返回登陆界面</a>
</body>
</html>