利用JSP实现简朴的用户登录注册页面示例代码解

将尝试2中的系统用户登录和注册页面改为JSP页面,并陈设本身的Web应用于Tomcat处事器中

详细要求:

完成登录JSP页面设计和注册页面设计

在登录页面表单中利用request工具获取用户信息,成立新的JSP页面完成登录验证(用户名和暗码本身指定即可)。

验证功效显示(如登录乐成/用户名暗码错误,可以利用JavaScript,也可以利用新的JSP页面)。

在注册页面表单中利用request工具获取用户注册信息(注册项目由本身指定),在新的JSP页面显示用户注册信息,并提示注册乐成。

代码

登录页面index.html

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1"> <title>jsp功课</title> <link href="https://www.jb51.net/css/bootstrap.min.css"> </head> <body> <nav> <div> <div> <a href="" >jsp功课</a> </div> <div> <ul> <li><a href="https://www.jb51.net/login.jsp" >登录</a></li> </ul> </div> </div> </nav> <div> <div> <h1>Hello, world!</h1> <p>这是一个jsp功课</p> </div> </div> </body> </html>

登录页面login.jsp

<%@ page contentType="text/html; charset=utf-8" language="java"%> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1"> <title>登录</title> <link href="https://www.jb51.net/css/bootstrap.min.css"> </head> <body> <nav> <div> <div> <a href="" >jsp功课</a> </div> <div> <ul> <li><a href="https://www.jb51.net/login.jsp" >登录</a></li> </ul> </div> </div> </nav> <div> <div> <div> </div> <div> <form method="post" action="login-check.jsp"> <h2>登录到jsp功课</h2> <label for="">用户名</label> <input type="text" placeholder="请输入用户名" required autofocus><br> <label for="">暗码</label> <input type="password" placeholder="请输入暗码" required> <div> <label> <input type="checkbox" value="remember-me" checked="checked"> 记着暗码 </label> </div> <button type="submit">登录</button> <a href="https://www.jb51.net/reg.jsp">注册</a> </form> </div> <div> </div> </div> </body> </html>

登录功效页面login-check.jsp

<%@ page contentType="text/html; charset=utf-8" language="java"%> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1"> <title>登录</title> <link href="https://www.jb51.net/css/bootstrap.min.css"> </head> <body> <nav> <div> <div> <a href="" >jsp功课</a> </div> <div> <ul> <li><a href="https://www.jb51.net/login.jsp" >登录</a></li> </ul> </div> </div> </nav> <div> <div> <div> </div> <div> <form method="post" action="login-check.jsp"> <h2>登录到jsp功课</h2> <label for="">用户名</label> <input type="text" placeholder="请输入用户名" required autofocus><br> <label for="">暗码</label> <input type="password" placeholder="请输入暗码" required> <div> <label> <input type="checkbox" value="remember-me" checked="checked"> 记着暗码 </label> </div> <button type="submit">登录</button> <a href="https://www.jb51.net/reg.jsp">注册</a> </form> </div> <div> </div> </div> </body> </html>

注册页面reg.jsp

<%@ page contentType="text/html; charset=utf-8" language="java"%> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1"> <title>注册</title> <link href="https://www.jb51.net/css/bootstrap.min.css"> </head> <body> <nav> <div> <div> <a href="" >jsp功课</a> </div> <div> <ul> <li><a href="https://www.jb51.net/login.jsp" >登录</a></li> </ul> </div> </div> </nav> <div> <div> <div> </div> <div> <form action="reg-submit.jsp" method="post"> <h2>注册到jsp功课</h2> <div> </div> <label for="">用户名</label> <input type="text" placeholder="请输入用户名" required autofocus><br> <label for="">暗码</label> <input type="password" placeholder="请输入暗码" required><br> <label for="">反复暗码</label> <input type="password" placeholder="请再次输入暗码" required maxLength="16"><br> <button type="submit">注册</button> <a href="https://www.jb51.net/login.jsp">返回登录</a> </form> </div> <div> </div> </div> </body> </html>

注册功效页面reg-submit.jsp

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsddfy.html