留下邮箱,我做过一个,发给你,注销你自己写吧,只要把session置空就行了,我的程序里你可以在一个超链接里面写session.getAttribute("uname")=null;,在跳转到登陆界面就行了www.zgxue.com防采集请勿采集本网。
实验要求:
不建议用js,很容易就查到用户名和密码 asp简单认证 <%@LANGUAGE="V submit" name="button" id="button" value="登录"
将实验2中的系统用户登录和注册页面改为JSP页面,并部署自己的Web应用于Tomcat服务器中
V是view,是现实显示层,也就是用jsp来做,注意,在jsp中要尽量少用java脚本,这也是我们的 用户名或者密码不存在或错误,就跳转到登陆失败提示页面。呵呵,我已经尽量简洁的说
具体要求:
同意1楼的方法,我来写具体点吧。 首先要在后台接收这个数据。 Sting username = request.getParameter("这里写JSP页面中用户名文本框的name"); Sting passw
完成登录JSP页面设计和注册页面设计
本文实例讲述了纯JSP实现的简单登录的方法。分享给大家供大家参考,具体如下: 文件 登录失败:用户名或密码不正确~ <% } } %> </body> </html> logout.jsp源
在登录页面表单中使用request对象获取用户信息,建立新的JSP页面完成登录验证(用户名和密码自己指定即可)。
把驱动包放在项目下,看下数据库是不是打开了、
验证结果显示(如登录成功/用户名密码错误,可以使用JavaScript,也可以使用新的JSP页面)。
// end else if my_mc.cat._visible =0; dati = filexml.firstChild.childNodes[categoriasito].childNodes; for (i=0; i<dati.length; i++) { my_mc.cat.duplicateMovieClip("cat&quo
在注册页面表单中使用request对象获取用户注册信息(注册项目由自己指定),在新的JSP页面显示用户注册信息,并提示注册成功。
登陆验证 你就有javaScript 写,登录界面这东西应该是最简单的了,你是学习还是其它的方面要自己使用?
代码
登录页面index.html
注: 由于时间仓促,程序可能有细小的问题!但绝对可以满足你的需要了!如果你知道JSP什 while(rs.next()) { out.println("登陆成功!"); out.println("您的用户名是:
<!DOCTYPE html><html lang="zh-CN"><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jsp作业</title> <link href="css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet"></head><body><nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="./" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >jsp作业</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> <li><a href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >登录</a></li> </ul> </div> </div></nav><div class="container"> <div class="jumbotron"> <h1>Hello, world!</h1> <p>这是一个jsp作业</p> </div></div></body></html>
在数据库中多加一列 在注册的时候 在注册信息默认为一个数值 管理员 为另一个数值 这样不就区分 权限不就 很好分配
登录页面login.jsp
可以凭借Baiduhi提示我们 有机会能够处理你所遇到的工作 相关的要求也能够提示我们 ES:\\7F2C225C4AB23C90446118FA3092DF35 交易提醒:预付定金有
<%@ 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 name="viewport" content="width=device-width, initial-scale=1"> <title>登录</title> <link href="css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet"></head><body><nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="./" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >jsp作业</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> <li><a href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >登录</a></li> </ul> </div> </div></nav><div class="container"> <div class="row"> <div class="col-md-4"> </div> <div class="col-md-4"> <form class="form-signin" method="post" action="login-check.jsp"> <h2 class="form-signin-heading">登录到jsp作业</h2> <label for="">用户名</label> <input type="text" name="username" id="username" class="form-control" placeholder="请输入用户名" required autofocus><br> <label for="">密码</label> <input type="password" name="password" id="password" class="form-control" placeholder="请输入密码" required> <div class="checkbox"> <label> <input type="checkbox" value="remember-me" checked="checked"> 记住密码 </label> </div> <button type="submit" class="btn btn-primary" id="btn-login">登录</button> <a href="reg.jsp" rel="external nofollow" rel="external nofollow" class="btn btn-default">注册</a> </form> </div> <div class="col-md-4"> </div> </div></body></html>
晕,这个只要判断一下就可以了嘛。 比如: String username = request.getParameter("login"); String sql = "select * from 用户表 where 用户名='"+username
登录结果页面login-check.jsp
String name="user.xml"; private static String filename; //写一个静态块实现对 <a href='index.jsp'>返回登录</a>"); }else{ out.print("用户名和密码不
<%@ 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 name="viewport" content="width=device-width, initial-scale=1"> <title>登录</title> <link href="css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet"></head><body><nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="./" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >jsp作业</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> <li><a href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >登录</a></li> </ul> </div> </div></nav><div class="container"> <div class="row"> <div class="col-md-4"> </div> <div class="col-md-4"> <form class="form-signin" method="post" action="login-check.jsp"> <h2 class="form-signin-heading">登录到jsp作业</h2> <label for="">用户名</label> <input type="text" name="username" id="username" class="form-control" placeholder="请输入用户名" required autofocus><br> <label for="">密码</label> <input type="password" name="password" id="password" class="form-control" placeholder="请输入密码" required> <div class="checkbox"> <label> <input type="checkbox" value="remember-me" checked="checked"> 记住密码 </label> </div> <button type="submit" class="btn btn-primary" id="btn-login">登录</button> <a href="reg.jsp" rel="external nofollow" rel="external nofollow" class="btn btn-default">注册</a> </form> </div> <div class="col-md-4"> </div> </div></body></html>
晕,这个只要判断一下就可以了嘛。 比如: String username = request.getParameter("login"); String sql = "select * from 用户表 where 用户名='"+username
注册页面reg.jsp
JSP+JDBC留言管理程序(代码+笔记),项目02_使用JSP完成简单的登陆程序(代码+笔记),项目03_JSP+DAO留言管理程序(代码+笔记),项目04_使用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 name="viewport" content="width=device-width, initial-scale=1"> <title>注册</title> <link href="css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet"></head><body><nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="./" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >jsp作业</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> <li><a href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >登录</a></li> </ul> </div> </div></nav><div class="container"> <div class="row"> <div class="col-md-4"> </div> <div class="col-md-4"> <form class="form-signin" action="reg-submit.jsp" method="post"> <h2 class="form-signin-heading">注册到jsp作业</h2> <div id="info"> </div> <label for="">用户名</label> <input type="text" name="username" id="username" class="form-control" placeholder="请输入用户名" required autofocus><br> <label for="">密码</label> <input type="password" name="password" id="password" class="form-control" placeholder="请输入密码" required><br> <label for="">重复密码</label> <input type="password" name="password2" id="password2" class="form-control" placeholder="请再次输入密码" required maxLength="16"><br> <button type="submit" class="btn btn-primary" id="btn-reg">注册</button> <a href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-default" id="btn-reg">返回登录</a> </form> </div> <div class="col-md-4"> </div> </div></body></html>
不建议用js,很容易就查到用户名和密码 asp简单认证 <%@LANGUAGE="VB submit" name="button" id="button" value="登录"
注册结果页面reg-submit.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 name="viewport" content="width=device-width, initial-scale=1"> <title>结果</title> <link href="css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="stylesheet"></head><body><nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="./" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >jsp作业</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-right"> <li><a href="login.jsp" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >登录</a></li> </ul> </div> </div></nav><div class="container"> <% String username = request.getParameter("username"); String password = request.getParameter("password"); String password2 = request.getParameter("password2"); %> <% if(password.equals(password2)){ out.println("<div class='alert alert-success' role='alert'>注册成功</div>"); out.println("<ul class='list-group'>"); out.println("<li class='list-group-item'>用户名:" + username + "</li>"); out.println("<li class='list-group-item'>密码:" + password + "</li>"); out.println("</ul>"); } else{ out.println("<div class='alert alert-danger' role='alert'>两次密码输入不一致,请重新输入</div>"); } %> <!-- <%=username %> <%=password %> <%=password2 %> --></div>
效果
到此这篇关于使用JSP实现简单的用户登录注册页面示例代码解析的文章就介绍到这了,更多相关JSP实现简单的用户登录注册页面内容请搜索真格学网以前的文章或继续浏览下面的相关文章希望大家以后多多支持真格学网!
参考如下:<form action="dologin" method="post" name="frm"> 用户名: <input type="text" name="username" id="username"> <br/> 密码:<input type="password" name="userpwd" id="userpwd"> <br/> <input type="submit" name="subbtn"value="登录"> <input type="reset" name="rebtn"value="取消"></form>servlet:// 设置编码request.setCharacterEncoding("utf-8");response.setCharacterEncoding("utf-8");response.setContentType("text/html;charset=utf-8");// 获取参数String username = request.getParameter("username");String userpwd = request.getParameter("userpwd");// 输出流PrintWriter out = response.getWriter();HttpSession session = request.getSession(true);// UserDao userdao = new UserDao();User user = null;try {user = userdao.getUser(username);} catch (Exception e1) {e1.printStackTrace();}// 登录判断if(!(user== null) &&(user.getPassword().equals(userpwd))){// 存放到session中session.setAttribute("user", user);// 重定向response.sendRedirect("index.jsp");}else{// 登录失败提示out.print("<script>alert('登录失败,请重新登录!!');window.location.href='login.jsp';</script>");}}内容来自www.zgxue.com请勿采集。