jsp使用cookie实现记住密码的功能,该如何处理

jsp使用cookie实现记住密码的功能
jsp使用cookie实现记住密码的功能,代码怎么写的。这个问题困扰我很长时间了,请高手帮帮我。在登陆界面,如果用户点击记住密码复选框,在下次打开登录界面时候用户名和密码不用输入,已经在文本框中!请高手一定要帮帮我,我真的很急。先谢谢大家了!

------解决方案--------------------
JAVA
取数据。其中 request 是 HttpServletRequest 对象
Java code

Cookie[] cookies = request.getCookies();
for (int i = 0; cookies != null && i < cookies.length; i++) {
    System.out.println(cookies[i].getName() + "=" + cookies[i].getValue());
}

------解决方案--------------------
1.这个一个页面模拟的cookie,如果你要实现登录,当用户输入用户名密码时,到控制层用
Cookie user = new Cookie("user",name+"-"+passward);
加到cookie中,然后在访问此登录页面时,就先调用
Cookie[] cookies=request.getCookies(); 看cookie中是否有user这个值,如果有就取得用户名、密码。
代码示例:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String name="nihao";
String passward="nihao";
try{
Cookie user = new Cookie("user",name+"-"+passward);
user.setMaxAge(60);
response.addCookie(user);
Cookie[] cookies=request.getCookies();
if(cookies!=null){
for(int i=0;i<cookies.length;i++){
if(cookies[i].getName().equals("user")){
name=cookies[i].getValue().split("-")[0];
passward=cookies[i].getValue().split("-")[1];
request.setAttribute("name",name);
request.setAttribute("pass",passward);
}
}
}
}catch(Exception e){
e.printStackTrace();
}

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></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">
-->

</head>

<body>
<form action="test10.jsp" method="post">
<input type="text" value="${name}" name=name /></br>
<input type="text" value="${pass}" name=pass />
<input type="submit" value="提交">
</form>
</body>
</html>