login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <style type="text/css"> div{ text-align: center; margin: 0 auto; } .password{ width:200px; } body{ background: white; } .sub{ width:300px; } h1 { color:orange; text-size:20px; } </style> </head> <body> <div> <h1>学生登陆</h1> <form action="dologin.jsp" method="post"> 学号:<input type="text" name="uname" class="name"><br> 密码:<input type="password" name="upassword" class="password"><br> 验证码:<input type="password" name="upassword" class="password"><br> <input type="submit" value="登录" class="sub"> </form> </div> </body> </html>
dologin.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String name=request.getParameter("uname"); String password=request.getParameter("upassword"); if(name.equals("zs")&&password.equals("123")){ request.getRequestDispatcher("ok.jsp").forward(request,response); }else{ request.getRequestDispatcher("no.jsp").forward(request,response); } %>
loginOK.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <h1>登陆成功</h1> </body> </html>
loginFail.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> <h1>登陆失败</h1> </body> </html>