151126
<%@ 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> <form action ="yanzheng.jsp" method="post"> 用户:<input type="text" name="userid" width=30/> 密码:<input type="password" name="password" width=30/> <input type="submit" value="登录" /> </form> </body> </html>
<%@ 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 strUserid =request.getParameter("userid"); String strPW =request.getParameter("password"); if(strUserid == null || strUserid.trim().length() == 0) { response.sendRedirect("message.jsp?msgid=1"); } else if(strPW == null || strPW.trim().length() == 0) { response.sendRedirect("message.jsp?msgid=2"); } else {//查找用户信息 String strUID ="zhangsan"; String strP ="123"; if(strUserid.equals(strUID)) { if(strPW.equals(strP)) { out.print("欢迎登陆"); //跳转到系统页面 } else { response.sendRedirect("message.jsp?msgid=3"); } } else { response.sendRedirect("message.jsp?msgid=4"); } } %> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.*" %> <!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 strMsgId =request.getParameter("msgid"); if(strMsgId == null || strMsgId.trim().length()==0) { out.print("信息错误"); } else { int iMsgid = Integer.parseInt(strMsgId); switch (iMsgid) { case 1: out.print("账号输入错误"); break; case 2: out.print("密码输入错误"); break; case 3: out.print("密码错误"); break; case 4: out.print("用户不存在"); break; default: out.print("无法识别信息"); break; } } response.setHeader("refresh","5;URL=Login.jsp"); %> </body> </html>