Using nl.captcha.servlet.SimpleCaptchaServlet
instead of nl.captcha.servlet.StickyCaptchaServlet
solved the problem
because StickyCaptchaServlet
uses the SessionId to create the image and SimpleCaptchaServlet
doesn't
Question
I'm using SimpleCaptcha
My web.xml looks like the one here:
<servlet>
<servlet-name>StickyCaptcha</servlet-name>
<servlet-class>nl.captcha.servlet.StickyCaptchaServlet</servlet-class>
<init-param>
<param-name>width</param-name>
<param-value>250</param-value>
</init-param>
<init-param>
<param-name>height</param-name>
<param-value>75</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>StickyCaptcha</servlet-name>
<url-pattern>/captcha</url-pattern>
</servlet-mapping>
And i added a refresh but to my view like described in this SO-answer:
<script type="text/javascript">
function reloadCaptcha(){
var d = new Date();
$("#captcha_image").attr("src", "/captcha?"+d.getTime());
}
</script>
...
<img id="captcha_image" src="/captcha_generator.jsp" alt="captcha image" width="200" height="50"/>
<img src="reload.jpg" onclick="reloadCaptcha()" alt="reload"width="40" height="40"/>
But when i press the refresh button, nothing happens.
Also when i try to call .../captcha?4324321
it still prints the same captcha (based on the user session as i understood it)
I'm also using spring-mvc and spring-webflow.
La solution
Using nl.captcha.servlet.SimpleCaptchaServlet
instead of nl.captcha.servlet.StickyCaptchaServlet
solved the problem
because StickyCaptchaServlet
uses the SessionId to create the image and SimpleCaptchaServlet
doesn't
Autres conseils
I think you may try: $("#captcha_image").attr("src", "/captcha_generator.jsp"); instead of: $("#captcha_image").attr("src", "/captcha?"+d.getTime());