Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
<dependency>
	<groupId>com.octo.captcha</groupId>
	<artifactId>jcaptcha</artifactId>
	<version>1.0-SNAPSHOT<0</version>
</dependency>

Without Maven2

Add jcaptcha-all.jar (provided in bin-distribution) and commons-collection-3.2 or greater (not provided see commons collection ) to your application class path, ie in you WEB-INF/lib folder.

...

Implement a CaptchaService

Note
titleIt must be a singleton

...

Code Block
Boolean isResponseCorrect =Boolean.FALSE;
           //remenber that we need an id to validate!
           String captchaId = httpServletRequest.getSession().getId();
           //retrieve the response
           String response = httpServletRequest.getParameter("j_captcha_response");
           // Call the Service method
            try {
                isResponseCorrect = CaptchaServiceSingleton.getInstance().validateResponseForID(captchaId,
                        response);
            } catch (CaptchaServiceException e) {
                 //should not happen, may be thrown if the id is not valid
            }

//do something according to the result!

Want some more

Tipinfo
titleTry customization and more integration

Have a look to the modules provided to see how to integrate it with other frameworks :

Tip
titleContribute !

Please put some code showing integration with a new framework in a child page of the How To