日期:2014-05-16 浏览次数:20337 次
jsp页面:
<%@ page contentType="text/html;charset=gbk"%>
<%@ page language="java" %>
<%@ page import="java.util.*"%>
<%
response.setHeader("Cache-Control", "no-cache");
String username="";//session.getAttribute("username")==null?"":(String)session.getAttribute("username");
%>
<%
??Random rand = new Random();??
??Integer?? flag =new?? Integer(rand.nextInt());
??String str_flag = flag.toString();
??session.setAttribute("flag",str_flag);?
?%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>test</title>
</head>
<body>
<table>
?
<form id="form1" action="usercheck.test" name="form1">
<tr>
?<td width="25%" height="25" align="right">帐户:</td>
?<td>
?<input?? type=hidden?? name="flag"?? value="<%=str_flag%>"/>
?<input name="username" type="text" class="text" id="account" value="<%=username %>" maxlength="10"/>
? <span id="account_span"></span>
?</td>
?<td height="25" colspan="2">
?<input id="jccf" style="margin-left:300px" type="button" name="Submit" onclick="checkusername();" value="提交"/>
?</td>
?</tr>
?<tr>
??? <td>第四行赋的值是:</td>
??? <td><script>document.write(document.form1.flag.value)</script></td>
? </tr>
</table>
</form>
<script script="javascript">
function checkusername()
{
??form1.submit();
}
document.getElementById('username').focus();
</script>
</body>
</head>
Java:
package cn;
import java.io.*;