BotDetect Java CAPTCHA Web API Reference

To make Captcha integration into Java websites easy, the BotDetect Java CAPTCHA Library exposes a public API focused on ease of use from JSP forms.

botdetect.web.Captcha

Instances of Captcha type can be created on your forms and will take care of Captcha display and validation. Captcha object is also implicitly created by BotDetect Captcha Custom Tag.

Captcha Class Reference
BotDetect Java CAPTCHA Library Reference: Captcha class public static method Captcha load (ServletRequest request) Returns Captcha instance. Id is retreived from request.
BotDetect Java CAPTCHA Library Reference: Captcha class public static method Captcha load (ServletRequest request, String captchaId) Returns a new Captcha instance.
BotDetect Java CAPTCHA Library Reference: Captcha class public property String get/ CaptchaId Unique identifier of the Captcha object within the application (for example, if you placed one Captcha object on the Registration page and another on the Contact Us page, they would have distinct CaptchaId values).
BotDetect Java CAPTCHA Library Reference: Captcha class public property String get/ CurrentInstanceId Globally unique identifier of the current Captcha object instance, used to ensure each page load keeps separate Captcha codes, for example when opening the same form in multiple browser tabs.
BotDetect Java CAPTCHA Library Reference: Captcha class public property int get/set CodeLength Length (number of characters) of the Captcha code rendered; the default value is between 4 and 6.
BotDetect Java CAPTCHA Library Reference: Captcha class public property CodeStyle get/set CodeStyle Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric.
BotDetect Java CAPTCHA Library Reference: Captcha class public property ImageStyle /set ImageStyle Image style, i.e. the algorithm used to render Captcha codes in images; if no image style is set, it is randomized by default.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setImageStyle( List<ImageStyle> usedStyles) Sets a List of Image styles randomly used to render Captcha image.
BotDetect Java CAPTCHA Library Reference: Captcha class public property ImageSize get/set ImageSize Size of the Captcha image rendered; the default size is (250, 50).
BotDetect Java CAPTCHA Library Reference: Captcha class public property ImageFormat get/set ImageFormat Image format in which the Captcha image will be rendered; the default format is JPEG.
BotDetect Java CAPTCHA Library Reference: Captcha class public property boolean is/set ReloadEnabled Controls whether Captcha reloading is enabled (is the reload icon and related code added to Captcha markup).
BotDetect Java CAPTCHA Library Reference: Captcha class public property boolean is/set CaptchaSoundEnabled Controls whether Captcha sound is enabled (is the sound icon and related code added to Captcha markup).
BotDetect Java CAPTCHA Library Reference: Captcha class public property boolean get/set UserInputClientId User input textbox client-side identifier, used for Captcha validation and all client-side user input processing, e.g. automatic user input lowercasing and focusing.
BotDetect Java CAPTCHA Library Reference: Captcha class public property boolean is/set HelpLinkEnabled Is the Captcha help link enabled (depends on license).
BotDetect Java CAPTCHA Library Reference: Captcha class public property HelpLinkMode is/set HelpLinkMode Select whether help link will be Captcha image (image) or text under Captcha image (text). Default is text.
BotDetect Java CAPTCHA Library Reference: Captcha class public property boolean is/set IncludeClientScript If set to false prevents renderCaptchaMarkup method to render HTML markup for BotDetect Client Script. Default is true.
BotDetect Java CAPTCHA Library Reference: Captcha class public method String getClientScriptMarkup( String contextPath) Returns HTML markup for BotDetect Client Script.
BotDetect Java CAPTCHA Library Reference: Captcha class public property boolean is/set IncludeStyle If set to false prevents renderCaptchaMarkup method to render HTML markup for BotDetect Stylesheet. Default is true.
BotDetect Java CAPTCHA Library Reference: Captcha class public method String getStylesheetMarkup( String contextPath) Returns HTML markup for BotDetect Stylesheet.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void renderCaptchaMarkup( ServletContext ctx, Writer out) Generates the Html markup needed to add the current Captcha object instance to a form.
BotDetect Java CAPTCHA Library Reference: Captcha class public method boolean validate( HttpServletRequest request, String userInput) Validates the Captcha, comparing the user input to the Captcha code stored on the server. Each randomly generated Captcha code can only be validated once, regardless of the validation result.

botdetect.web.jsf.JsfCaptcha

Intended to be used with JavaServer Faces. Extends UIComponentBase so it is easy to add it to your form while binding with JSF managed bean's property allows more dynamic control of Captcha object.

JsfCaptcha Class Reference
BotDetect Java CAPTCHA Library Reference: Captcha class public constructor JsfCaptcha() The JsfCaptcha constructor has no parameters because id is assigned through attribute value on the page.
BotDetect Java CAPTCHA Library Reference: Captcha class public method boolean validate(String userInput) Validates the Captcha, comparing the user input to the Captcha code stored on the server. Each randomly generated Captcha code can only be validated once, regardless of the validation result.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setCodeLength(int length) Sets length (number of characters) of the Captcha code rendered; the default value is between 4 and 6.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setImageWidth(int width) Width of the Captcha image rendered; the default width is 250 pixels.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setImageHeight(int height) Height of the Captcha image rendered; the default height is 50 pixels.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setCodeStyle(CodeStyle height) Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setImageStyle(ImageStyle style) Image style, i.e. the algorithm used to render Captcha codes in images; if no image style is set, it is randomized by default.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setImageStyles(String styles) Comma delimited string of Image styles randomly used to render Captcha image.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setImageFormat(ImageFormat format) Image format in which the Captcha image will be rendered; the default format is JPEG.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setHelpLinkEnabled(boolean value) Sets whether is the Captcha help link enabled (depends on license).
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setHelpLinkMode(HelpLinkMode mode) Select whether help link will be Captcha image (image) or text under Captcha image (text). Default is text.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setReloadEnabled(boolean value) Sets whether Captcha reloading is enabled (is the reload icon and related code added to Captcha markup). Default is true.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setSoundEnabled(boolean value) Sets whether Captcha sound is enabled (is the sound icon and related code added to Captcha markup). Default is true.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setUserInputClientId(String value) User input textbox client-side identifier, used for Captcha validation and all client-side user input processing, e.g. automatic user input lowercasing and focusing.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setOmitStylesheet(boolean value) If set to true prevents JsfCaptcha rendering method to render HTML markup for BotDetect stylesheet. Default is false.
BotDetect Java CAPTCHA Library Reference: Captcha class public method void setOmitClientScript(boolean value) If set to true prevents JsfCaptcha rendering method to render HTML markup for BotDetect Client Script. Default is false.

Please Note

BotDetect Java Captcha Library v4.0.Beta3 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.