Downloads for Captcha.jar:
HTTP://PAN.BAIDU.COM/S/1WAXBG Extraction Code: h216
deployment of Captcha:
The captcha jar is introduced into the project;
configuring in Web. XML
<servlet><servlet-name>Kaptcha</servlet-name><servlet-class> Com.google.code.kaptcha.servlet.kaptchaservlet</servlet-class></servlet> <servlet-mapping > <servlet-name>Kaptcha</servlet-name> <url-pattern>/randomcode.jpg</ Url-pattern> </servlet-mapping>
detailed configuration of the Web. xml file:
<!--login Verification code Kaptcha 2--><servlet><servlet-name>kaptcha</servlet-name><servlet-class> com.google.code.kaptcha.servlet.kaptchaservlet</servlet-class><init-param><description> picture Border, Legal value: Yes, no</description><param-name>kaptcha.border</param-name><param-value>yes</ param-value></init-param><init-param><description> border color, legal value: r,g,b (and optional alpha) or White ,black,blue.</description><param-name>kaptcha.border.color</param-name><param-value> black</param-value></init-param><init-param><description> border thickness, legal value: >0</ description><param-name>kaptcha.border.thickness</param-name><param-value>1</ param-value></init-param><init-param><description> Picture Width 400</description>< Param-name>kaptcha.image.width</param-name><param-value>200</param-value></init-param ><init-param><descripTion> Pictures High 50</description><param-name>kaptcha.image.height</param-name><param-value> 50</param-value></init-param><init-param><description> Picture Implementation Class </description>< Param-name>kaptcha.producer.impl</param-name><param-value> com.google.code.kaptcha.impl.defaultkaptcha</param-value></init-param><init-param>< Description> Text Implementation class </description><param-name>kaptcha.textproducer.impl</param-name>< param-value>com.google.code.kaptcha.text.impl.defaulttextcreator</param-value></init-param>< Init-param><description> text collection, validation code value gets from this collection </description><param-name> Kaptcha.textproducer.char.string</param-name><param-value>1234567890</param-value> <!-- <param-value>abcde2345678gfynmnpwx</param-value>--><!--<param-value> mu Lesson Network Tutorial Verification Code Instance </ param-value>--></init-param><init-param><description> Verification Code length 5</description><param-name>kaptcha.textproducer.char.length</param-name><param-value>4 </param-value></init-param><init-param><description> Font Arial, courier</description ><param-name>kaptcha.textproducer.font.names</param-name><param-value>arial, Courier</ param-value></init-param><init-param><description> Font Size 40px.</description>< param-name>kaptcha.textproducer.font.size</param-name><param-value>40</param-value></ init-param><init-param><description> font Color, legal value: R,g,b or white,black,blue.</description>< Param-name>kaptcha.textproducer.font.color</param-name><param-value>black</param-value> </init-param><init-param><description> text Interval 2</description><param-name> Kaptcha.textproducer.char.space</param-name><param-value>2</param-value></init-param> <init-param><descriptioN> interference Implementation Class </description><param-name>kaptcha.noise.impl</param-name><param-value><!- -Com.google.code.kaptcha.impl.NoNoise-->com.google.code.kaptcha.impl.defaultnoise</param-value></ init-param><init-param><description> interference color, legal value: R,g,b or white,black,blue.</description>< param-name>kaptcha.noise.color</param-name><param-value>white</param-value></ Init-param><init-param><description> Picture Style: Watermark Com.google.code.kaptcha.impl.WaterRipple Fish Eye com.google.code.kaptcha.impl.FishEyeGimpy Shadow Com.google.code.kaptcha.impl.Shado Wgimpy</description><param-name>kaptcha.obscurificator.impl</param-name><param-value> com.google.code.kaptcha.impl.fisheyegimpy</param-value></init-param><init-param>< Description> Background Implementation class </description><param-name>kaptcha.background.impl</param-name>< Param-value>com.google.code.kaptcha.impl.defaultbackground</param-value></init-param><init-param><description> background color gradient, starting color </description><param-name >kaptcha.background.clear.from</param-name><param-value>green</param-value></ init-param><init-param><description> background color gradient, end color </description><param-name> Kaptcha.background.clear.to</param-name><param-value>white</param-value></init-param> <init-param><description> Text Renderer </description><param-name>kaptcha.word.impl</ param-name><param-value>com.google.code.kaptcha.text.impl.defaultwordrenderer</param-value>< Key key to store verification code in/init-param><init-param><description>session </description><param-name> kaptcha.session.key</param-name><param-value>kaptcha_session_key</param-value></ Init-param><init-param><description>the date The Kaptcha is generated was put into thehttpsession. This is the key value for the, item in ThesessioN.</description><param-name>kaptcha.session.date</param-name><param-value>kaptcha_ Session_date</param-value></init-param></servlet> <servlet-mapping> <servlet-name> Kaptcha</servlet-name> <url-pattern>/randomcode.jpg</url-pattern> </servlet-mapping>
Example:
Front:
<body> <form action= "check.jsp" > <input type= "text" name= "code" > /randomcode.jpg ' > <br> <input type= "Submit" value= "Submission" > </form> </body>
for validation: check.jsp
<body> <% string key= (String) session.getattribute (Constants.kaptcha_session_key); String code=request.getparameter ("code"); if (key.equals (code)) { Out.print ("true"); } Out.print ("key=" +key+ "-----" + "code=" +code); %> </body>
Promotion:
In this blog view: Algorithm verification code, Chinese verification Code
About the use of the CAPTCHA Verification code component