Class StickyCaptchaServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
nl.captcha.servlet.SimpleCaptchaServlet
nl.captcha.servlet.StickyCaptchaServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class StickyCaptchaServlet extends SimpleCaptchaServlet
Builds a 200x50 (default) CAPTCHA and attaches it to the session. This is intended to help prevent bots from simply reloading the page and getting new images until one is generated which they can successfully parse. Removal of the session attribute CaptchaServletUtil.NAME will force a new Captcha to be added to the session.

Image height and width may be customized by adding the "heigh" and "width" init-params to web.xml. For example:

    <servlet>        
        <servlet-name>StickyCaptcha</servlet-name>
        <servlet-class>nl.captcha.servlet.StickyCaptchaServlet</servlet-class>
        <init-param>
            <param-name>width</param-name>
            <param-value>250</param-value>
        </init-param>
        <init-param>
            <param-name>height</param-name>
            <param-value>75</param-value>
        </init-param>
    </servlet>
See Also:
  • Field Summary

    Fields inherited from class nl.captcha.servlet.SimpleCaptchaServlet

    _height, _width

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Write out the CAPTCHA image stored in the session.

    Methods inherited from class nl.captcha.servlet.SimpleCaptchaServlet

    init

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, init, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StickyCaptchaServlet

      public StickyCaptchaServlet()
  • Method Details

    • doGet

      public void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException
      Write out the CAPTCHA image stored in the session. If not present, generate a new <code>Captcha</code> and write out its image.
      Overrides:
      doGet in class SimpleCaptchaServlet
      Throws:
      jakarta.servlet.ServletException
      IOException