While I was working on a Struts 2 Project, I wanted to add captcha support to some of my forms. For those who are not familiar with the name, captcha is that small image with letters in forms asking you to type whatever in there (CAPTHCA = Completely Automated Public Test to tell Computers and Humans Apart). So, my first stop was to check the Struts 2 Plugin Repository to find out whether there’s a plugin which can do that. But I had no luck there, and I thought of Googling for some library which could help me with this. I found JCaptcha, an interesting library with lots of features and customizability.
Looking through the product, I found several guides which shows integration of JCaptcha with classic JSP/Servlets, Struts etc, but nothing for Struts 2. When I closely followed the JSP/Servlet example, it was obvious that writing a Struts 2 application to do the same is “no big deal”, but there are some things to be done. So I thought how cool if there was a plugin to do this.
Finally, since I had this idea of trying to develop a plugin for Struts 2 for sometime, I thought of giving it a try, and JCaptcha4Struts2 was born. JCaptcha4Struts2 allows smooth integration of JCaptcha and Struts2, and provides a JSP tag library which developers can use to put a JCaptcha image validation component to their forms with through a single JSP Tag. It supports transparent captcha validation through a base action class or alternatively, through intercepters. If the interceptors are used, it requires slight configuration in the struts.xml file.
The plugin binaries, source, javadoc and a sample web app is available for download in the project site at http://code.google.com/p/jcaptcha4struts2/. Currently the project supports only image captcha generation (where as JCaptcha supports various engines, and captcha types such as sound captcha). Also no i18n support is available yet. I am still working on those areas of the plugin in my free time.