P142-1

P142-1.1 登录页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isErrorPage="true"%>
<%@ page import="java.net.URLEncoder" %>
<!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> <form name="login" method="post" action="P142-1.3.jsp">
用户名:
<input name="uersname" type="text" width="30" />
<br>
密码:<input name="password" type="password" width="30" />
<br>
<input type="submit" value="登录"/>
</form>
</form>
</body>
</html>

P142-1.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>
<%
response.setHeader("refresh","3;P142-1.1.jsp");
%>
您输入的密码有误!
<br>
<a href="P142-1.1.jsp">3秒后将返回登录页面,或点击此处返回</a> </body>
</html>

P142-1.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>登录信息处理</title>
</head>
<body>
<% String un = request.getParameter("usersname"); String pw = request.getParameter("password"); if(un == null || un.trim().length() == 0)
{
out.print("请输入正确的用户名");
}
else if(pw == null || pw.trim().length() == 0)
{
out.print("请输入正确的密码");
}
else
{
//查找用户信息
String yonghu = "duke";
String mima = "zxczxc"; if(un.equals(yonghu))
{
if(pw.equals(mima))
{
out.print("登录成功");
response.sendRedirect("P142-2.1.jsp");
}
else
{
response.sendRedirect("P142-1.2.jsp");
}
}
else
{
out.print("该用户不存在,请注册");
}
} %> </body>
</html>
上一篇:我对android开发的一点小感悟小看法


下一篇:显式激活数据库( ACTIVATE DATABASE)