<%... @ Page contenttype = "text/html; charset = GBK" Language = "Java" Import = "Java. SQL. *" errorpage = "" %>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = GBK"/>
<Title> JSP uses cookies to remember the user name and password </title>
</Head>
<%...
If (request. getparameter ("send ")! = NULL)
{
Cookie = new cookie (request. getparameter ("userno"), request. getparameter ("password "));
Cookie. setmaxage (360*24*60*60 );
Response. addcookie (cookie );
}
Cookie Cookies [] = request. getcookies ();
Cookie scookie = NULL;
String svalue = NULL;
String sname = NULL;
%>
<Script language = "JavaScript">...
VaR userno = new array (); userno [0] = "";
VaR Password = new array (); password [0] = "";
</SCRIPT>
<%...
For (INT I = 0; I <cookies. length; I ++ ){
Scookie = Cookies [I];
%>
<Script language = "JavaScript">...
Userno [<% = I %>] = "<% = scookie. getname () %> ";
Password [<% = I %>] = "<% = scookie. getvalue () %> ";
</SCRIPT>
<%...
Out. Print (scookie. getname () + "+ scookie. getvalue () +" </BR> ");
}
%>
<Body>
<Form ID = "form1" name = "form1" method = "Post" Action = "">
<P>
<Input type = "text" name = "userno"/>
<Input type = "Submit" name = "send" value = "S"/>
</P>
<P>
<Input type = "text" name = "password" onclick = "Return ouserno_onchange ()"/>
</P>
</Form>
</Body>
</Html>
<Script language = JavaScript>...
Function ouserno_onchange ()...{
For (I = 0; I <userno. length; I ++)
If (form1.userno. value = userno [I])
Form1.password. value = PASSWORD [I];
}
</SCRIPT>