主頁 > 知識(shí)庫 > 使用JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄注冊(cè)頁面示例代碼解析

使用JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄注冊(cè)頁面示例代碼解析

熱門標(biāo)簽:電話機(jī)器人需要使用網(wǎng)絡(luò)嗎 電銷機(jī)器人免培訓(xùn) 自繪地圖標(biāo)注數(shù)據(jù) 南通通訊外呼系統(tǒng)產(chǎn)品介紹 如何看懂地圖標(biāo)注點(diǎn) 外呼系統(tǒng)使用方法 海外圖書館地圖標(biāo)注點(diǎn) 潤(rùn)滑油銷售電銷機(jī)器人 給地圖標(biāo)注得傭金

實(shí)驗(yàn)要求:

將實(shí)驗(yàn)2中的系統(tǒng)用戶登錄和注冊(cè)頁面改為JSP頁面,并部署自己的Web應(yīng)用于Tomcat服務(wù)器中

具體要求:

完成登錄JSP頁面設(shè)計(jì)和注冊(cè)頁面設(shè)計(jì)

在登錄頁面表單中使用request對(duì)象獲取用戶信息,建立新的JSP頁面完成登錄驗(yàn)證(用戶名和密碼自己指定即可)。

驗(yàn)證結(jié)果顯示(如登錄成功/用戶名密碼錯(cuò)誤,可以使用JavaScript,也可以使用新的JSP頁面)。

在注冊(cè)頁面表單中使用request對(duì)象獲取用戶注冊(cè)信息(注冊(cè)項(xiàng)目由自己指定),在新的JSP頁面顯示用戶注冊(cè)信息,并提示注冊(cè)成功。

代碼

登錄頁面index.html

!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作業(yè)/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作業(yè)/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>這是一個(gè)jsp作業(yè)/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 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作業(yè)/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">登錄到j(luò)sp作業(yè)/h2>
    label for="">用戶名/label>
    input type="text" name="username" id="username" class="form-control" placeholder="請(qǐng)輸入用戶名" required autofocus>br>
    label for="">密碼/label>
    input type="password" name="password" id="password" class="form-control" placeholder="請(qǐng)輸入密碼" 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">注冊(cè)/a>
   /form>
  /div>
  div class="col-md-4">
  /div>
 /div>
/body>
/html>

登錄結(jié)果頁面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 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作業(yè)/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">登錄到j(luò)sp作業(yè)/h2>
    label for="">用戶名/label>
    input type="text" name="username" id="username" class="form-control" placeholder="請(qǐng)輸入用戶名" required autofocus>br>
    label for="">密碼/label>
    input type="password" name="password" id="password" class="form-control" placeholder="請(qǐng)輸入密碼" 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">注冊(cè)/a>
   /form>
  /div>
  div class="col-md-4">
  /div>
 /div>
/body>
/html>

注冊(cè)頁面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 name="viewport" content="width=device-width, initial-scale=1">
 title>注冊(cè)/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作業(yè)/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">注冊(cè)到j(luò)sp作業(yè)/h2>
    div id="info">

    /div>
    label for="">用戶名/label>
    input type="text" name="username" id="username" class="form-control" placeholder="請(qǐng)輸入用戶名" required autofocus>br>
    label for="">密碼/label>
    input type="password" name="password" id="password" class="form-control" placeholder="請(qǐng)輸入密碼" required>br>
    label for="">重復(fù)密碼/label>
    input type="password" name="password2" id="password2" class="form-control" placeholder="請(qǐng)?jiān)俅屋斎朊艽a" required maxLength="16">br>
    button type="submit" class="btn btn-primary" id="btn-reg">注冊(cè)/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>

注冊(cè)結(jié)果頁面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>結(jié)果/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作業(yè)/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'>注冊(cè)成功/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'>兩次密碼輸入不一致,請(qǐng)重新輸入/div>");
 }
 %>
 !-- %=username %>
 %=password %>
 %=password2 %> -->
/div>

效果





到此這篇關(guān)于使用JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄注冊(cè)頁面示例代碼解析的文章就介紹到這了,更多相關(guān)JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄注冊(cè)頁面內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • jsp+dao+bean+servlet(MVC模式)實(shí)現(xiàn)簡(jiǎn)單用戶登錄和注冊(cè)頁面
  • jsp實(shí)現(xiàn)用戶自動(dòng)登錄功能
  • jsp實(shí)現(xiàn)簡(jiǎn)單用戶7天內(nèi)免登錄
  • servlet+jsp實(shí)現(xiàn)過濾器 防止用戶未登錄訪問
  • JSP Spring防止用戶重復(fù)登錄的實(shí)現(xiàn)方法
  • JavaWeb實(shí)現(xiàn)用戶登錄注冊(cè)功能實(shí)例代碼(基于Servlet+JSP+JavaBean模式)
  • JSP實(shí)現(xiàn)用戶登錄、注冊(cè)和退出功能
  • jsp基于XML實(shí)現(xiàn)用戶登錄與注冊(cè)的實(shí)例解析(附源碼)
  • JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄并顯示出用戶信息的方法
  • 在jsp中用bean和servlet聯(lián)合實(shí)現(xiàn)用戶注冊(cè)、登錄
  • 關(guān)于JSP用戶登錄連接數(shù)據(jù)庫詳情

標(biāo)簽:樂山 南京 黃石 廣州 內(nèi)江 銅川 貸款邀約 大連

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《使用JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄注冊(cè)頁面示例代碼解析》,本文關(guān)鍵詞  使用,JSP,實(shí)現(xiàn),簡(jiǎn)單,的,用戶,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《使用JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄注冊(cè)頁面示例代碼解析》相關(guān)的同類信息!
  • 本頁收集關(guān)于使用JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄注冊(cè)頁面示例代碼解析的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章