好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識(shí)庫 > 純JSP實(shí)現(xiàn)的簡(jiǎn)單登錄示例

純JSP實(shí)現(xiàn)的簡(jiǎn)單登錄示例

熱門標(biāo)簽:南京新思維電話機(jī)器人 聊城智能電銷機(jī)器人外呼 企業(yè)怎么在聯(lián)通申請(qǐng)400電話 泰州泰興400電話 怎么申請(qǐng) 地圖標(biāo)注市場(chǎng)怎么樣 百度地圖添加標(biāo)注圖標(biāo)樣式 南昌市地圖標(biāo)注app 如何用中國(guó)地圖標(biāo)注數(shù)字點(diǎn) 好操作的電話機(jī)器人廠家

本文實(shí)例講述了純JSP實(shí)現(xiàn)的簡(jiǎn)單登錄的方法。分享給大家供大家參考,具體如下:

文件共有四個(gè)web.xml、login.jsp、logout.jsp、welcome.jsp四個(gè)文件

測(cè)試環(huán)境:Tomcat 6.0.x

假設(shè)項(xiàng)目名稱是LoginSample,我的目錄結(jié)構(gòu)是這樣的

...\webapps\LoginSample\WEB-INF\web.xml
...\webapps\LoginSample\login.jsp
...\webapps\LoginSample\logout.jsp
...\webapps\LoginSample\welcome.jsp

web.xml源碼清單:

web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
  welcome-file-list>
    welcome-file>welcome.jsp/welcome-file>
  /welcome-file-list>
/web-app>

login.jsp源碼清單:

%@ page contentType="text/html;charset=UTF-8" %>
html>
 head>
  title>JSP簡(jiǎn)單登錄實(shí)例/title>
 /head>
 body>
 h2>請(qǐng)登錄/h2>
 form method="POST" >
  Login Name: input type="text" name="Name">br>
  Login Password: input type="text" name="Password" >br>
  input type="submit" value="Send">br>
 form>
 %
   if (request.getParameter("Name") != null
        request.getParameter("Password") != null) {
     String Name = request.getParameter("Name");
     String Password = request.getParameter("Password");
     if (Name.equals("a")  Password.equals("a")) {
       session.setAttribute("Login", "OK");
       session.setAttribute("myCount", new Integer(1));
       response.sendRedirect("welcome.jsp");
     }
     else {
       %>
       登錄失敗:用戶名或密碼不正確~
       %
     }
   }
%>
 /body>
/html>

logout.jsp源碼清單:

%@ page contentType="text/html;charset=UTF-8" %>
html>
 %
  session.setAttribute("Login", "");
 %>
 body>
 h2>你已經(jīng)退出登錄/h2>
 /body>
/html>

welcome.jsp源碼清單:

%@ page contentType="text/html" pageEncoding="UTF-8" import="java.util.*"%>
html>
 body>
 h2>歡迎頁面(測(cè)試session)/h2>
 %
 String Login = (String)session.getAttribute("Login");
 int   nCount=0;
 if (Login != null  Login.equals("OK")) {
   Integer myCount = (Integer)session.getAttribute("myCount");
   if(myCount!=null)
   {
     nCount = myCount.intValue();
     nCount = nCount + 1;
     session.setAttribute("myCount",new Integer(nCount));
   }
   %>
   登錄成功,myCount=%=nCount%>/br>
   input type=button value="退出" onclick="javascript:location.href='logout.jsp'">
   %
 }
 else {
%>
   jsp:forward page="login.jsp"/>
%
  }
  %>
  /body>
/html>

希望本文所述對(duì)大家JSP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • JSP中實(shí)現(xiàn)系統(tǒng)登錄后的退出原理及代碼
  • java(jsp)整合discuz同步登錄功能詳解
  • JSP實(shí)現(xiàn)簡(jiǎn)單的用戶登錄并顯示出用戶信息的方法
  • 在jsp中用bean和servlet聯(lián)合實(shí)現(xiàn)用戶注冊(cè)、登錄
  • JSP+Servlet+JavaBean實(shí)現(xiàn)登錄網(wǎng)頁實(shí)例詳解
  • JBuilder2005實(shí)戰(zhàn)JSP之登錄頁面實(shí)現(xiàn)代碼[圖]
  • jsp基于XML實(shí)現(xiàn)用戶登錄與注冊(cè)的實(shí)例解析(附源碼)
  • JSP實(shí)現(xiàn)用戶登錄、注冊(cè)和退出功能
  • JavaWeb實(shí)現(xiàn)用戶登錄注冊(cè)功能實(shí)例代碼(基于Servlet+JSP+JavaBean模式)
  • JSP+Servlet制作Java Web登錄功能的全流程解析
  • Servlet+JavaBean+JSP打造Java Web注冊(cè)與登錄功能

標(biāo)簽:烏蘭察布 吉林 銅川 山南 臨汾 開封 自貢 白銀

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《純JSP實(shí)現(xiàn)的簡(jiǎn)單登錄示例》,本文關(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)單登錄示例》相關(guān)的同類信息!
  • 本頁收集關(guān)于純JSP實(shí)現(xiàn)的簡(jiǎn)單登錄示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章