bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

用Cookie實現一天免登錄功能-創新互聯

Servlet程序:

創新互聯從2013年創立,先為明水等服務建站,明水等地企業,進行企業商務咨詢服務。為明水企業網站制作PC+手機+微官網三網同步一站式服務解決您的所有建站問題。
package com.westos.untitle2;

import com.westos.untitle2.CityService.UserService;
import com.westos.untitle2.bean.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "Cookie4Servlet")
public class Cookie4Servlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         response.setCharacterEncoding("utf-8");
         request.setCharacterEncoding("utf-8");
         response.setContentType("text/html;charset=utf-8");
         String username=request.getParameter("username");
         String password=request.getParameter("password");
         UserService userService=new UserService();
         List<User> list=userService.setUser();
         if (username==null||password==null){
            Cookie[] cookie=request.getCookies();
            for (Cookie c:cookie){
                if(c.getName().equals("username")){
                    username=c.getValue();
                }else if(c.getName().equals("password")){
                    password=c.getValue();
                }
            }
        }
        if(username.equals("")||password.equals("")){
            request.getRequestDispatcher("login2.html").forward(request,response);
        }else{
            for(User user:list){
                if(user.getUsername().equals(username)&&user.getPassword().equals(password)){
                    Cookie cookie1=new Cookie("username",username);
                    Cookie cookie2=new Cookie("password",password);
                    cookie1.setMaxAge(60*60);
                    cookie2.setMaxAge(60*60);
                    response.addCookie(cookie1);
                    response.addCookie(cookie2);
                    request.getRequestDispatcher("success.html").forward(request,response);
                }else{
                    request.getRequestDispatcher("login2.html").forward(request,response);
                }
            }
        }
    }
}

登錄頁面程序:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登錄</title>
</head>
<body>
<form action="./cookie4" method="Post" name="login">
    昵稱:<input name="username" type="text" placeholder="請輸入昵稱" id="nicheng"/><br/><br/>
    密碼:<input name="password" type="password" placeholder="請輸入密碼" id="mima"/><br/><br/>
    請輸入驗證碼:<br/>
    <img src="./yzm01" height="32" id="myyzm">
    <button type="button" value="看不清楚,再來一張" onclick="identifyload()">看不清楚,再來一張</button>
    <input name="yzm01" type="text"/><br/>
    <button type="submit" value="登錄" >登錄</button>
    <button type="reset" value="重置">重置</button>
</form>
</body>
</html>

User:

public class User {
    private String Username;
    private String password;

    public String getUsername() {
        return Username;
    }

    public String getPassword() {
        return password;
    }

    public void setUsername(String username) {
        Username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}

UserService:

package com.westos.untitle2.CityService;

import com.westos.untitle2.bean.User;
import sun.rmi.log.LogInputStream;

import java.util.ArrayList;
import java.util.List;

public class UserService {
    public List<User> setUser(){
        List<User> list=new ArrayList<>();
        User u1=new User();
        u1.setUsername("Bighead");
        u1.setPassword("4214963");
        list.add(u1);
        User u2=new User();
        u2.setUsername("lyy");
        u2.setPassword("0829");
        list.add(u2);
        return list;
    }
}

success.html程序,自己根據需求設置.

創新互聯www.cdcxhl.cn,專業提供香港、美國云服務器,動態BGP最優骨干路由自動選擇,持續穩定高效的網絡助力業務部署。公司持有工信部辦法的idc、isp許可證, 機房獨有T級流量清洗系統配攻擊溯源,準確進行流量調度,確保服務器高可用性。佳節活動現已開啟,新人活動云服務器買多久送多久。

網站題目:用Cookie實現一天免登錄功能-創新互聯
本文路徑:http://vcdvsql.cn/article14/cdgpde.html

成都網站建設公司_創新互聯,為您提供網站導航、靜態網站、網站排名定制網站搜索引擎優化動態網站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

商城網站建設