Menu

#8 Simple Captcha

v1.1
open
Dennis M
None
5
2015-06-11
2009-05-27
Anonymous
No

Hey I found a bug in your project. In SimpleCaptchaServlet, you have to swap the last two line. You need to create your session before sending the picture :
req.getSession().setAttribute(NAME, captcha);
CaptchaServletUtil.writeImage(resp, captcha.getImage());

You didn't make the mistake for the ChineseCaptchaServlet and the Sticky one...

But great job, your project is very useful !

Discussion

  • James Childers

    James Childers - 2009-05-29
    • assigned_to: nobody --> dennis2681
     
  • Dennis M

    Dennis M - 2009-06-01

    Does this really make any difference? I tested the current code and it seems to work fine unless I'm missing something...

     
  • Nobody/Anonymous

    It doesn't work fine...!!!

    I tested it with Tomcat v6, and java throwed me an java.lang.IllegalStateException : not possible to create a session after the reponse has been send...

    Then I swaped the two lines, as I explained above.

    This really makes a difference, because without that, the server doesn't send a JSESSIONID to the client !!!

     
  • Nobody/Anonymous

    """CaptchaServletUtil.writeImage(resp, captcha.getImage()); """ sends data to the client,
    but your web server needs to be aware that you want to send these datas with a jsession id.

    The only solution, is to write req.getSession().setAttribute(NAME, captcha); before sending datas.

     
  • Dennis M

    Dennis M - 2009-06-05

    Ok, fair enough. What version of Tomcat are you using? I'm using Tomcat 6.0.14 and I do not see this issue.

     
  • Nobody/Anonymous

    I'm using Tomcat 6.0.18 (on Windows)

     
  • Lars Herschke

    Lars Herschke - 2015-06-11

    I think it's because the following Tomcat-bug

    https://wiki.apache.org/tomcat/FAQ/KnownIssues#ImageIOIssues

    The swap of the two lines was sufficient for me.

     

Log in to post a comment.