Name:
Password:
remember me
or register
Valid XHTML 1.0 Transitional Valid CSS! SourceForge.net Logo
Creating a captcha with JSP
Theory

A captcha is an image with some text in it. The whole idea is to  have a user read the image and post it with the message he wants to add (ie. in a forum). The reason behind this is to prevent automated postings in forums/guestbooks/...

There are quite a few solutions out there, but most are hard to implement and/or need a lot of extra software. An easy solution is to simply let the captcha be generated by a tool like imagemagick .

The captcha

Creating a captcha with magemagick is really simple. Just open a command line and call imagemagick with:

convert background.png -gravity center -font arial.ttf -pointsize 37 -annotate 0 'test' -fill yellow -draw "path 'M 5,12 L 195,12 M 5,18 L 195,18 M 5,25 L 195,25'" -wave 5x108 -swirl 13 captcha.png

 As background image (background.png) you can use pretty much every image you find (make sure its not too big and has a light background).

This creates a simple captcha with a text, some swirl and  kinda wavy.

You can easily script this call with Runtime processes in java and generate your own captchas.

Usage and Code
You can get a working code from the Corinis wiki. there you will also find  the information you need to implement this in your solution