日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

JSP的Cookie在登錄中的使用

瀏覽:740日期:2022-06-07 09:30:06

JSP的Cookie在登錄中的使用

一 功能需求

實(shí)現(xiàn)記憶用戶(hù)名和密碼功能。

二 代碼

1、login.jsp

<%@ page language="java" import="java.util.*,java.net.*" contentType="text/html; charset=utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <title>My JSP "index.jsp" starting page</title>    <meta http-equiv="pragma" content="no-cache">    <meta http-equiv="cache-control" content="no-cache">    <meta http-equiv="expires" content="0">      <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="This is my page">    <!--    <link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    --> </head>  <body>  <h1>用戶(hù)登錄</h1>  <hr>  <%   request.setCharacterEncoding("utf-8");   String username="";   String password = "";   Cookie[] cookies = request.getCookies();   if(cookies!=null&&cookies.length>0)   {      for(Cookie c:cookies)      {       if(c.getName().equals("username"))       {  username = URLDecoder.decode(c.getValue(),"utf-8");       }       if(c.getName().equals("password"))       {  password = URLDecoder.decode(c.getValue(),"utf-8");       }      }   }  %>  <form name="loginForm" action="dologin.jsp" method="post">    <table>     <tr>      <td>用戶(hù)名:</td>      <td><input type="text" name="username" value="<%=username %>"/></td>     </tr>     <tr>      <td>密碼:</td>      <td><input type="password" name="password" value="<%=password %>" /></td>     </tr>     <tr>      <td colspan="2"><input type="checkbox" name="isUseCookie" checked="checked"/>十天內(nèi)記住我的登錄狀態(tài)</td>     </tr>     <tr>      <td colspan="2" align="center"><input type="submit" value="登錄"/><input type="reset" value="取消"/></td>     </tr>    </table>  </form> </body></html>

2、dologin.jsp

<%@ page language="java" import="java.util.*,java.net.*" contentType="text/html; charset=utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <title>My JSP "dologin.jsp" starting page</title>      <meta http-equiv="pragma" content="no-cache">    <meta http-equiv="cache-control" content="no-cache">    <meta http-equiv="expires" content="0">      <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="This is my page">    <!--    <link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    -->  </head>  <body>  <h1>登錄成功</h1>  <hr>  <br>  <br>  <br>  <%    request.setCharacterEncoding("utf-8");    //首先判斷用戶(hù)是否選擇了記住登錄狀態(tài)    String[] isUseCookies = request.getParameterValues("isUseCookie");    if(isUseCookies!=null&&isUseCookies.length>0)    {     //把用戶(hù)名和密碼保存在Cookie對(duì)象里面     String username = URLEncoder.encode(request.getParameter("username"),"utf-8");     //使用URLEncoder解決無(wú)法在Cookie當(dāng)中保存中文字符串問(wèn)題     String password = URLEncoder.encode(request.getParameter("password"),"utf-8");          Cookie usernameCookie = new Cookie("username",username);     Cookie passwordCookie = new Cookie("password",password);     usernameCookie.setMaxAge(864000);     passwordCookie.setMaxAge(864000);//設(shè)置最大生存期限為10天     response.addCookie(usernameCookie);     response.addCookie(passwordCookie);    }    else    {     Cookie[] cookies = request.getCookies();     if(cookies!=null&&cookies.length>0)     {       for(Cookie c:cookies)       {if(c.getName().equals("username")||c.getName().equals("password")){  c.setMaxAge(0); //設(shè)置Cookie失效  response.addCookie(c); //重新保存。}       }     }    }  %>  <a href="users.jsp" rel="external nofollow" target="_blank">查看用戶(hù)信息</a>   </body> </html>

3、users.jsp

<%@ page language="java" import="java.util.*,java.net.*" contentType="text/html; charset=utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head>  <base href="<%=basePath%>" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    <title>My JSP "users.jsp" starting page</title>      <meta http-equiv="pragma" content="no-cache">    <meta http-equiv="cache-control" content="no-cache">    <meta http-equiv="expires" content="0">      <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="This is my page">    <!--    <link rel="stylesheet" type="text/css" href="styles.css" rel="external nofollow" rel="external nofollow" rel="external nofollow" >    -->  </head>  <body>  <h1>用戶(hù)信息</h1>  <hr>  <%   request.setCharacterEncoding("utf-8");   String username="";   String password = "";   Cookie[] cookies = request.getCookies();   if(cookies!=null&&cookies.length>0)   {      for(Cookie c:cookies)      {       if(c.getName().equals("username"))       {  username = URLDecoder.decode(c.getValue(),"utf-8");       }       if(c.getName().equals("password"))       {  password = URLDecoder.decode(c.getValue(),"utf-8");       }      }   }  %>  <BR>  <BR>  <BR>     用戶(hù)名:<%=username %><br>     密碼:<%=password %><br> </body></html>

三 測(cè)試

如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

標(biāo)簽: JSP
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
国产九一精品| 欧美特黄一区| 日本成人在线不卡视频| 亚洲一区二区小说| 一级欧美视频| 日韩福利在线观看| 国产精品一区二区三区www | 韩国三级一区| 久久国产亚洲| 在线亚洲欧美| 亚洲精品欧美| 日韩高清三区| 久久wwww| 日韩精品诱惑一区?区三区| 日本高清不卡一区二区三区视频| 激情久久久久久久| 蜜臀av亚洲一区中文字幕| 亚洲一区有码| 国产精品一区二区精品| 成人国产精品一区二区免费麻豆| 日韩欧美一区二区三区免费观看| 欧美精选一区二区三区| 蜜桃久久精品一区二区| 日韩av三区| 精品亚洲成人| 久久蜜桃精品| 午夜在线精品| 久久国产日韩欧美精品| 麻豆视频在线观看免费网站黄| 久久久天天操| 中文字幕av一区二区三区人| 国产精品久久久亚洲一区| 国产福利片在线观看| 伊人久久亚洲影院| 国产日产精品一区二区三区四区的观看方式| 欧美国产亚洲精品| 亚洲成人精品| 日本在线视频一区二区| 久久久久久一区二区| 婷婷亚洲五月| 欧美精品观看| а√天堂8资源在线| 一区视频在线| 国产精品成人一区二区网站软件| 亚洲爱爱视频| 日韩精品免费一区二区夜夜嗨 | 国产一二在线播放| 天使萌一区二区三区免费观看| 日本视频在线一区| 日韩精品久久久久久久电影99爱| 亚洲精品护士| 中文在线а√天堂| 日韩制服丝袜先锋影音| 成人在线观看免费视频| 石原莉奈一区二区三区在线观看| 欧美国产三级| 狠狠色综合网| 精品中国亚洲| 只有精品亚洲| 日韩专区精品| 国产私拍福利精品视频二区| 久久一区二区三区喷水| 国产欧美日韩免费观看| 在线一区免费| 成人日韩av| 日韩成人精品一区二区三区| 香蕉视频亚洲一级| 亚洲精品三级| 日韩另类视频| 国产精品一区二区三区四区在线观看| 欧美精品一区二区久久| 精品国产aⅴ| 日韩免费精品| 午夜久久黄色| 国产粉嫩在线观看| 国产日韩在线观看视频| 狠狠爱成人网| 97人人精品| 国产日韩中文在线中文字幕| 日韩亚洲在线| 日韩精品永久网址| 欧美aa在线视频| 久久亚洲影院| 婷婷成人在线| 国产福利91精品一区二区| 日韩视频1区| 快she精品国产999| 激情久久中文字幕| 国产自产自拍视频在线观看| 国产精品夜夜夜| 亚洲精品日韩久久| 天使萌一区二区三区免费观看| 欧美日韩尤物久久| 国产在线一区不卡| 国产麻豆一区二区三区精品视频| 亚洲日韩视频| 天堂av在线一区| 久久精品免费一区二区三区| 精品三级久久久| 国产日韩一区二区三免费高清| 亚洲色图国产| 最新亚洲激情| 亚洲国产日韩欧美在线| 婷婷激情一区| 在线亚洲人成| 成人在线视频免费看| 久久久国产精品网站| 国产探花在线精品| 国产欧美日韩一区二区三区在线| 婷婷精品在线| 亚洲精品美女91| 亚洲精品自拍| 每日更新成人在线视频| 伊人久久亚洲美女图片| 国产韩日影视精品| 欧美一区二区三区高清视频 | 久久影院资源站| 久久wwww| 精品日韩一区| 国产一区二区三区天码| 麻豆久久一区二区| 美女性感视频久久| 麻豆精品av| 高清日韩中文字幕| 久久av导航| 国产亚洲在线观看| 亚洲天堂成人| 午夜久久免费观看| 91久久久久| 蜜桃免费网站一区二区三区| 水野朝阳av一区二区三区| 亚洲欧美日韩国产一区| 视频一区二区不卡| 日韩精品亚洲一区二区三区免费| 日韩精品欧美精品| 欧美综合精品| 免费在线成人| 国产精品精品| 亚洲成人精品| 国产精品免费看| 亚洲欧美在线专区| 久久国产88| 中文欧美日韩| 欧美 日韩 国产一区二区在线视频 | 欧美+日本+国产+在线a∨观看| 久久亚洲人体| 久久国产日韩欧美精品| 国产亚洲久久| 亚洲四虎影院| 欧美日韩免费观看一区=区三区| 亚洲一级黄色| av中文资源在线资源免费观看| 精品久久一区| 中文在线资源| 国产综合视频| 99在线|亚洲一区二区| 久久福利一区| 日韩av三区| 青青国产精品| 日韩av中文字幕一区二区| 91亚洲无吗| 亚洲人成毛片在线播放女女| 日韩高清成人在线| 亚洲精品无播放器在线播放| 岛国av免费在线观看| 超级白嫩亚洲国产第一| 国产欧美一区二区三区国产幕精品| 国产精品igao视频网网址不卡日韩| 久久超级碰碰| 天堂av在线| 国产精品成人一区二区网站软件| 国产精品美女午夜爽爽| 日韩高清一区在线| 欧美精品导航| 日韩在线不卡| 美女网站久久| 欧美国产不卡| 在线亚洲欧美| 国产精品美女久久久久久不卡| 日韩精品免费一区二区在线观看 | 精品久久久久久久| 99成人在线| 久久精品毛片| 美女精品在线观看| 精品美女视频| 石原莉奈一区二区三区在线观看| 久久中文字幕一区二区| 激情欧美国产欧美| 国产精品久久久网站| 亚洲激情不卡| 国产在视频一区二区三区吞精| 午夜国产一区二区| 美女视频黄免费的久久| 久久av一区| 亚洲永久av| 欧美一级网站| 国产午夜久久| 亚洲天堂资源| 国产精品地址| 亚洲欧洲av|