Reputation: 9465
We're using SimpleCaptcha http://simplecaptcha.sourceforge.net/ to creating a captcha in our registration form (running on Tomcat)
We create the captcha using:
Captcha captcha = new Captcha.Builder(300, 57).build();
and the captcha is displayed as follows:
But when I add more options to the captcha such as Captcha captcha = new Captcha.Builder(300, 57).addNoise().build();
, it's still displayed in the same way without the noise. I tried more options but still get the same results.
Does anyone know why this is happening please?
Thanks,
Kurt
Upvotes: 0
Views: 2072
Reputation: 18861
I tried the code above (with java 1.6 version) and it produces nothing. The reason is that you don't have .addText(). (I would have written this as a comment but I don't have enough reputation for it). This suggests to me that your code above isn't your actual code, maybe you forgot something when posting.
Here's what I use that works:
public class MyCaptchaServlet extends SimpleCaptchaServlet
{
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
Captcha captcha = new Captcha.Builder(120,40).addText().addBorder().gimp().addBackground(new GradiatedBackgroundProducer()).build();
CaptchaServletUtil.writeImage(response, captcha.getImage());
request.getSession().setAttribute(Captcha.NAME, captcha);
}
}
Adding .addNoise() just before .build() does show the noise.
Upvotes: 1