management:gapcha

This is a simple gapcha implementation which gives you a basic possibility to protect your forms from spam robots.

Parameters

BufferedImage

Name Required Default Type Description
id false   String The result variable name.
textVariableName false   Object/String States what variable name in the session to use to store the text for later retrieval.
numberOfCharacters false   Object/String How many chars to generate.
imageType false BufferedImage.TYPE_4BYTE_ABGR Object/String What kind of image do we want – look
at BufferedImage.TYPE_XXX for the available types.
fontName false Dialog Object/String The name of the font to use
fontStyle false Font.PLAIN Object/String Which style to use
fontSize false 18 Object/String The size of the font
fgColor false Black Object/String What color should the text have – colon separated RGBA-color
bgColor false White Object/String What color should the background have – colon separated RGBA-color
renderWidth false 200 Object/String How wide is the render canvas in pixels
align false left Object/String How should the text align: left, right or center
padTop false 4 Object/String If stated the text will have x pixels of padding above it
padBottom false 4 Object/String If stated the text will have x pixels of padding below it
padLeft false 4 Object/String If stated the text will have x pixels of padding left of it
padRight false 4 Object/String If stated the text will have x pixels of padding right of it
pad false   Object/String If stated the text will have x pixels of padding around it
maxRows false 20 Object/String

State the maximum numbers of rows the tag can extend the rendering to.

trimEdges false 0 Object/String Should the edges be trimmed or not.
0 = notrim, 1 = left, 2 = right, 3 = left and right
tileBackgroundImage false 0 Object/String State if the background image should
be tiled. 0 = no, 1 = horizontal, 2 = vertical, 3 = both
backgroundImageUrl false   Object/String The url of the background image to be used.
twirlAngle false   Object/String How much you want the image to be twirled.
marbleXScale false   Object/String How much you want the image distorted in x-scale.
marbleYScale false   Object/String How much you want the image distorted in y-scale.
marbleTurbulence false   Object/String How turbulent the distort should be.
marbleAmount false   Object/String How strong the distortion should be.
         


Example

This example first generates a captcha-image and the key to the text is stored in the session under the variable name “catpchaText”. Then we can send the variable with the form as a hidden field and on the target page read the captcha-text by using that variable as a key.

<common:gapcha id="catpchaImageUrl" textVariableName="catpchaText" numberOfCharacters="6" fontName="Arial" fontSize="26" fgColor="255:0:255:255" bgColor="0:0:33:55" padTop="20" padBottom="20" renderWidth="200" padLeft="35" />
<img src="<c:out value="${catpchaImageUrl}" escapeXml="false"/>" />
<form…>
<input type=”hidden” name=”captchaKey” value=”<c:out value="${catpchaText}"/>”/
</form>

Then on the other target page check the form field the user enters against 
<%= ( String ) request.getSession().getAttribute( (String)request.getParameter("captchaKey") ) %>



comments powered by Disqus