BotDetect Java CAPTCHA Generator

CAPTCHA Generator Features:


BotDetect Java Captcha generator allows you to easily add Captcha protection to various types of Java based web forms.

We'll use default BotDetect settings in all code snippets.

To see how powerful and customizable BotDetect is, check the BotDetect features demo.

1. Show a Captcha Challenge on the JSF Form

BotDetect Java Captcha provides a dedicated JavaServer Faces tag 'simpleJsfCaptcha'.

'simpleJsfCaptcha' integration steps depend on whether you use standard JSF (.jsp) or Facelets (.xhtml) view handler(s).

Standard JSF

  • declare taglib at the begining of the .jsp file:
  • <%@taglib prefix="botDetect" uri=""%>
  • add (optionaly) attribute prependId="false" to <h:form> opening tag
  • within the <form> insert:
  • <h:outputLabel for="captchaCode" 
      value="Retype the characters from the picture:"/>
    <botDetect:simpleJsfCaptcha id="exampleCaptcha" 
    <h:inputText id="captchaCode" value="#{captchaExampleBean.captchaCode}"/>

When you open your form in a browser, the markup given above should render similar as:

BotDetect CAPTCHA added to an JSP page

In order to later perform CAPTCHA validation simpleJsfCaptcha tag must be bound with the corresponding property of the backing bean. This backing bean property should be of the SimpleJsfCaptcha type, and include both getter and setter access:

import botdetect.web.jsf.SimpleJsfCaptcha;

private SimpleJsfCaptcha captcha;

public SimpleJsfCaptcha getCaptcha() {
   return captcha;

public void setCaptcha(SimpleJsfCaptcha captcha) {
   this.captcha = captcha;

2. Validate User's Captcha Input During Form Submission

On form submit, the Captcha validation result must be checked:

boolean isHuman = captcha.validate(captchaCode);
if (isHuman) {
  correctLabelVisible = true;
  incorrectLabelVisible = false;
} else {
  correctLabelVisible = false;
  incorrectLabelVisible = true;

3. Add BotDetect Java CAPTCHA Library Dependency

Here is how to add BotDetect Java CAPTCHA Library dependency in various dependency management scenarios:

To manually add BotDetect Captcha library to classpath, copy the following jar files from BotDetect Java download package to application's WEB-INF/lib folder:

  • botdetect-4.0.beta3.2.jar
  • botdetect-servlet-4.0.beta3.2.jar
  • botdetect-jsp20-4.0.beta3.2.jar
  • botdetect-jsf20-4.0.beta3.2.jar

In case your application uses JSF 1.2 you will need to copy the botdetect-jsf12-4.0.beta3.2.jar file instead of botdetect-jsf20-4.0.beta3.2.jar file.

To share BotDetect Captcha among multiple applications, these BotDetect jar files above should be copied into 'lib' directory of web container or application server's domain.

4. Register BotDetect Simple Captcha Servlet

Update your application configuration (web.xml) file.

  <servlet-name>BotDetect Captcha</servlet-name>
  <servlet-name>BotDetect Captcha</servlet-name>

5. Configure Captcha options

Configure captcha options in WEB-INF/botdetect.xml configuration file.

<?xml version="1.0" encoding="UTF-8"?>
<botdetect xmlns="" 



BotDetect Java CAPTCHA Free version

You can download BotDetect Java CAPTCHA library for free and use it immediately! Your forms can be protected from spam (and bots in general) in minutes.

Keep in mind that we offer basic email support for free to all BotDetect users. So if you need any assistance integrating BotDetect or have any questions or feedback, our Support department is at your disposal.

Once the BotDetect Captcha generator library has been integrated into your Java web application and you're satisfied with how it works, it's easy to upgrade your license if you need the extra features and options offered by commercial BotDetect versions.

BotDetect Java Captcha Free Download

BotDetect Java CAPTCHA System Requirements

OSApplication ServerJava

Supported Operating Systems:

  • Linux
  • Windows

Supported servers:

  • Apache Tomcat 5+
  • JBoss/WildFly 4+
  • WebSphere 6+
  • WebLogic 9+
  • GlassFish 2+
  • Resin 3+
  • Jetty 5+

Java/Servlet/JSP/JSF/HyperSQL Database:

  • Java 5+
  • Java Servlet 2.3+
  • JavaServer Pages 2.0+
  • JavaServer Faces 1.2+
  • HyperSQL Database 2.3+

Please Note

BotDetect Java Captcha Library v4.0.Beta3.2 is an in-progress port of BotDetect 4 Captcha, and we need you to guide our efforts towards a polished product. Please let us know if you encounter any bugs, implementation issues, or a usage scenario you would like to discuss.