[Simplecaptcha-usage] little problem using simplecaptcha
Brought to you by:
jchilders235
|
From: lilia i. <le...@ya...> - 2007-10-01 15:39:42
|
Hi,
I am developping a web site in J2EE/Struts 2 and I'm using simplecaptcha for the registration.
I have encountred a problem while displaying the captcha.
this is my jsp page containing the captcha:
-----------------------------------------------------------------------------------------------------------------------------------------
<html>
<body>
<s:form action="Logon" method="POST">
<tr>
<td colspan="2">
Login
</td>
<s:textfield name="cardNumber" label="Card Number"/>
<s:password name="password" label="Password"/>
<tr>
<td>
<img src="Captcha.jpg"/>
</td>
<td>
<input type="text" name="response"/>
</td>
</tr>
<s:submit value="Submit" align="center"/>
</s:form>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------------------------
and this is the execute method of my Logon action
public String execute() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
setResponse((String)session.getAttribute("response"));
/*
* Verification of the captcha response
*/
String captchaResponse = (String) session.getAttribute(nl.captcha.servlet.Constants.SIMPLE_CAPCHA_SESSION_KEY);
String parm = getResponse();
if (captchaResponse != null && parm != null) {
if (!captchaResponse.equals(parm)) {
setResponse("error");
return INPUT;
}
}
/*
* end of verification
*/
return SUCCESS;
}
-----------------------------------------------------------------------------------------------------------------------------------------
When I first load the jsp page, it shows a captcha, but if I give a bad response and click on submit, the page doesn't display another captcha. and when I click a second time on "submit", another captcha is displayed. and whatever how many times I click on "submit" without giving a response, the servlet displays a new captcha each time.
to be brief, the captcha doesn't appear when I load the page for the second time, but it shows on all the other times.
what can I do to fix this?
best regards
---------------------------------
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail |