jsp:验证码晚一步 急!!!

来源:百度知道 编辑:UC知道 时间:2024/09/27 16:01:55
验证的时候 总是上一次显示的图片里的字符才正确,两个jsp文件

makeCertPic.jsp

<%@page contentType="image/jpeg"%>
<jsp:useBean id="image" scope="page" class="pic.makeCertPic"/>
<% String str=image.getCertPic(0,0,response.getOutputStream());
session.setAttribute("certCode",str); %>

regedit.jsp

<%@ page contentType="text/html;charset=gb2312"%>
<form method="post" action="" name="myform">
验证码:
<input name="hiddenCode" type="hidden" value="<%=(String)session.getAttribute("certCode")%>">
<input name="certCode" type="text"><img src="makeCertPic.jsp">
<input type="submit" name="B1" onClick="return check()">
</form>

<script language="JavaScript">
func

这种问题一般是你的验证码是虚拟到内存中的,不能在页面简单验证,必须提交到action中验证

最好是在action中保留提交信息,验证失败再返回到验证页面,这样用户看不出页面有什么变化