實現企業郵箱登入驗證功能
阿新 • • 發佈:2018-11-28
需求說明
實現企業郵箱登入驗證功能
使用者通過JSP頁面輸入使用者名稱和密碼
如果使用者名稱為lucky,密碼為123456, 在歡迎頁面顯示“你好:lucky!”
如果驗證登入失敗,則返回登入頁面重新登入
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>郵箱登入驗證</title> </head> <body> <form action="process.jsp" method="post"> <table> <tr> <td align="right">使用者名稱:</td> <td><input type="text" name="u_name" /></td> </tr> <tr> <td align="right">密碼:</td> <td><input type="password" name="u_pswd" /></td> </tr> <tr> <td><input type="submit" value="提交" /></td> </tr> </table> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>驗證處理頁面</title> </head> <body> <% String name=request.getParameter("u_name"); String pswd=request.getParameter("u_pswd"); if(name.equals("lucky") && pswd.equals("123456")){ out.print("你好,"+name+"!"); request.getRequestDispatcher("success.jsp").forward(request, response); }else{ response.sendRedirect("Login.jsp"); } %> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>驗證成功頁面</title> </head> <body> <h1>驗證成功!</h1> <h2>你好, <% String name=request.getParameter("u_name"); out.print(name); %> </h2> </body> </html>