Cookie cookies[]=request.getCookies();
Cookie stCookie=null;
String password=null;
String passwordvalue=null;
String usernamevalue=null;
String cookiename = null;
String nameandpassword[]=new String[3];
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
stCookie = cookies[i];
cookiename = stCookie.getName();
if (cookiename!=null && cookiename.equalsIgnoreCase("db_password")) {
passwordvalue = stCookie.getValue();
password = passwordvalue;//.substring(8, passwordvalue.length()-3);
nameandpassword[1] = password.trim();
}
if (cookiename!=null && cookiename.equalsIgnoreCase("db_username")) {
usernamevalue = stCookie.getValue();
nameandpassword[0] = usernamevalue.trim();
}
}
}
<body>
<p>
<label for="LoginName">
用户名 / 邮箱:
</label>
<input class="text" type="text" id="LoginName" name="LoginName"
value="<%=nameandpassword[0]==null?"":nameandpassword[0] %>" />
</p>
<p>
<label for="Password">
密码:
</label>
<input class="text" type="password" value="<%=nameandpassword[1]==null?"":nameandpassword[1] %>" name="Password" id="Password" />
</p>
</body>