You may not have noticed, but the SimpleCaptcha doe
snot properly set the no-cache headers on the servlet
response stream. Therefore in Opera, you will get the
same image, which often does not match the session
key...That's not good.
You need to change the doGet method of the
nl.captcha.servlet.Captcha file from this:
public void doGet(HttpServletRequest
httpservletrequest, HttpServletResponse
httpservletresponse)
throws ServletException, IOException
{
String s = textProducer.getText();
httpservletrequest.getSession().setAttribute
("SIMPLE_CAPCHA_SESSION_KEY", s);
DefaultCaptchaIml defaultcaptchaiml = new
DefaultCaptchaIml(props);
defaultcaptchaiml.createImage
(httpservletresponse.getOutputStream(), s);
}
to this:
public void doGet(HttpServletRequest
httpservletrequest, HttpServletResponse
httpservletresponse)
throws ServletException, IOException
{
String s = textProducer.getText();
httpservletrequest.getSession().setAttribute
("SIMPLE_CAPCHA_SESSION_KEY", s);
DefaultCaptchaIml defaultcaptchaiml = new
DefaultCaptchaIml(props);
httpservletresponse.setHeader("Pragma", "no-
cache");
httpservletresponse.setHeader("Cache-
Control", "no-cache");
defaultcaptchaiml.createImage
(httpservletresponse.getOutputStream(), s);
}
This will prevent the cache problem.
Thanks.
Logged In: YES
user_id=1717301
Originator: NO
When will this be a part of a new release?
Logged In: YES
user_id=1717301
Originator: NO
Thx for the posting. This was really good to know.