在login.jsp页面接收三个参数,然后传递给image.jsp
下面是产生验证码的代码,现在需要把image.jsp中的g.setColor(getRandColor(200,250))中随机产生的背景色替换成g.setColor(int a,int b,int c)格式的三个参数,这里面的三个参数就是login.jsp中接收的三个参数。
login.jsp
<%@ page contentType="text/html;charset=gbk" %>
<%@ page language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登录</title>
<script language="javascript">
function loadimage(){
document.getElementById("randImage").src = "image.jsp?"+Math.random();
}
</script>
</head>
<body>
<table width="256" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<form action="validate.jsp" method="post" name="loginForm">
<tr>
<td><input style="width: 100px" type="text" maxlength="3" id="lab_l" name="lab_l" onafterpaste="this.value=this.value.replace(/\D/g,'')" onkeyup="this.value=this.value.replace(/\D/g,'')">
<input style="width: 100px" type="text" maxlength="5" id="lab_a" name="lab_a" onafterpaste="this.value=this.value.replace(/\D/g,'')" onkeyup="this.value=this.value.replace(/\D/g,'')">
<input style="width: 100px" type="text" maxlength="5" id="lab_b" name="lab_b" >
</td>
<td width="138" valign="middle" align="center"><img alt="code..." name="randImage" id="randImage" src="image.jsp" width="60" height="20" border="1" align="absmiddle"></td>
</tr>
<tr>
<td height="36" colspan="2" align="center" valign="middle"><a href="javascript:loadimage();"><font class=pt95>看不清点我</font></a></td>
</tr>
<tr>
<td height="36" colspan="2" align="center" valign="middle"><input type="submit" name="login" value="提交"></td>
</tr>
</form>
</table>
</body>
</html>
image.jsp:
<%@ page contentType="image/jpeg" import="java.awt.*,
java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
Color getRandColor(int fc,int bc)
{
Random random = new Random();
if(fc>255) fc=255;