BotDetect CAPTCHA Crash Course
On this page we demonstrate how easy it is to integrate BotDetect Captcha in your forms.
We'll use default BotDetect settings; to see how powerful and customizable BotDetect is, check the BotDetect features demo.
- PHP
- ASP.NET
- Java
- ASP Classic
1. Include CAPTCHA Library File
Include botdetect.jar
into your web application's library folder (application/WEB-INF/lib
). This file is included in the BotDetectComponentJSF download web archive.
If you want to share the Captcha library among multiple applications copy it to your web container's (or domain's) library folder.
2. Show a CAPTCHA Challenge on the Form
On the very top of the source file for the web form you want to protect against bots, add:
<%@page import="botdetect.web.Captcha"%>
On the web form you want to protect against bots, add:
<% // Adding BotDetect Captcha to the page Captcha captcha = Captcha.load(request, "exampleCaptcha"); captcha.renderCaptchaMarkup(pageContext.getServletContext(), pageContext.getOut()); %> <input id="captchaCodeTextBox" type="text" name="captchaCodeTextBox" />
3. Check User Input During Form Submission
When the form is submitted, the Captcha validation result must be checked:
<% if("POST".equalsIgnoreCase(request.getMethod())){ // validate the Captcha to check we're not dealing with a bot boolean isHuman = captcha.validate(request, request.getParameter("captchaCodeTextBox")); if(isHuman){ // TODO: Captcha validation passed, perform protected action } else { // TODO: Captcha validation failed, show error message } } %>
4. Configure your Application
Update your application configuration (web.xml
) file.
<servlet-name>BotDetect Captcha</servlet-name> <servlet-class>botdetect.web.http.CaptchaServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>BotDetect Captcha</servlet-name> <url-pattern>/botdetectcaptcha</url-pattern> </servlet-mapping>
BotDetect CAPTCHA Options
To find more about configuring BotDetect and integrating it in various usage scenarios, please check the getting started with BotDetect Captcha page.
Current BotDetect Versions
-
BotDetect ASP.NET CAPTCHA
2019-07-22v4.4.2 -
BotDetect Java CAPTCHA
2019-07-22v4.0.Beta3.7 -
BotDetect PHP CAPTCHA
2019-07-22v4.2.5