To extend SimpleCaptcha and customize your CAPTCHA, my understanding is that you'll have to create your own HttpServlet
(maybe extends SimpleCaptchaServlet
). To do so, I suggest to download the source code and to look at SimpleCaptchaServlet
or StickyCaptchaServlet
. This is what the doGet()
method of SimpleCaptchaServlet
looks like:
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Captcha captcha = new Captcha.Builder(_width, _height)
.addText()
.addBackground(new GradiatedBackgroundProducer())
.gimp()
.addNoise()
.addBorder()
.build();
CaptchaServletUtil.writeImage(resp, captcha.getImage());
req.getSession().setAttribute(NAME, captcha);
}
This should be self-explaining: create your own servlet and put your custom Captcha Builder code in the doGet()
method. Then, follow the instructions of the Installing section but, instead of using one of their servlet, declare yours in the web.xml
. Finally, package/deploy your application. An example is bundled in the source distribution under examples
. Check it out if you need more guidance about the structure, the dependencies and the packaging of your web application.