response.jsp %@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%%@ page import="java.util.*"% Insert title here %String userName=null;String pwd=null;Cookie[] cookies=request.getCookies();for(int i=0;cookies
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="java.util.*"%>userLogin.jspInsert title here <% String userName=null; String pwd=null; Cookie[] cookies=request.getCookies(); for(int i=0;cookies!=null &&i
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ page import="javax.servlet.http.*"%>运行截图.pngInsert title here <% String userName=request.getParameter("userName"); // 获取用户名 String pwd=request.getParameter("pwd"); // 获取密码 String remember=request.getParameter("remember"); // 获取记住密码 if("remember-me".equals(remember)){ Cookie userNameAndPwd=new Cookie("userNameAndPwd",userName+"-"+pwd); userNameAndPwd.setMaxAge(1*60*60*24*7); // cookie记录一个星期 response.addCookie(userNameAndPwd); // 保存cookie System.out.println("设置Cookie成功"); } response.sendRedirect("response.jsp"); %>