<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>JavaGeek.org - captcha tag</title>
  <link>http://javageek.org/tags/captcha/</link>
  <description>For the love of Java</description>
  <language>en</language>
  <copyright>Guillermo Castro</copyright>
  <lastBuildDate>Fri, 12 Nov 2010 16:04:24 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>Adding Captcha to your Pebble blog</title>
    <link>http://javageek.org/2006/01/31/adding_captcha_to_your_pebble_blog.html</link>
    
      
        <description>
          I started getting some spam comments on my blog a couple of weeks ago, at a steady increasing rate, which was getting very annoying. Fortunately, &lt;a href=&#034;http://blogs.bytecode.com.au/glen/2006/01/10/1136883229429.html&#034;&gt;I found a very simple way to add captcha validation&lt;/a&gt; to the add comments form. Unfortunately, Glen&#039;s solution involved patching the original pebble source and redeploying pebble. There is a better way, as I commented on his blog, which is to modify the&amp;nbsp; &lt;span style=&#034;font-weight: bold;&#034;&gt;addComment&lt;/span&gt; property inside the &lt;span style=&#034;font-style: italic;&#034;&gt;WEB-INF/classes/action.properties&lt;/span&gt; file to point to a new class where you add the captcha functionality. The main advantage of doing this is that you don&#039;t need to redeploy pebble, as you are only adding a new library. &lt;br /&gt;&lt;br /&gt;To make things even simpler, I&#039;m making the &#039;plugin&#039; (which is only the new class) available for &lt;a href=&#034;http://javageek.org/files/pebble-captcha.jar&#034;&gt;download&lt;/a&gt;. You only need to put this jar in the &lt;span style=&#034;font-style: italic;&#034;&gt;WEB-INF/lib&lt;/span&gt; folder of your pebble deployment, and modify the above property to look like this:&lt;br /&gt;
&lt;pre class=&#034;code&#034;&gt;addComment=org.javageek.pebble.controller.action.AddCommentAction&lt;/pre&gt;
Then restart pebble, and enjoy a spam-free blog, at least until the damn spammers figure out how to deal with captchas.&lt;br /&gt;&lt;br /&gt;&lt;span style=&#034;font-weight: bold;&#034;&gt;UPDATE&lt;/span&gt;: I forgot to mention that you also need to modify &lt;i&gt;common/jsp/commentsForm.jspf&lt;/i&gt; to add the captcha validation:&lt;br /&gt;
&lt;pre class=&#034;code&#034;&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;   &amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Math Quiz&lt;br /&gt;     &amp;lt;% java.util.Random rnd = new java.util.Random(); %&amp;gt;&lt;br /&gt;       &amp;lt;c:set var=&amp;quot;captcha1&amp;quot; scope=&amp;quot;session&amp;quot;&amp;gt;&lt;br /&gt;         &amp;lt;%= rnd.nextInt(10) + 1 %&amp;gt;&lt;br /&gt;       &amp;lt;/c:set&amp;gt;&lt;br /&gt;       &amp;lt;c:set var=&amp;quot;captcha2&amp;quot; scope=&amp;quot;session&amp;quot;&amp;gt;&lt;br /&gt;         &amp;lt;%= rnd.nextInt(10) + 1 %&amp;gt;&lt;br /&gt;       &amp;lt;/c:set&amp;gt;&lt;br /&gt;       &amp;lt;c:out value=&amp;quot;${captcha1}&amp;quot;/&amp;gt; + &amp;lt;c:out value=&amp;quot;${captcha2}&amp;quot;/&amp;gt; =&lt;br /&gt;       &amp;lt;/b&amp;gt;&lt;br /&gt;   &amp;lt;/td&amp;gt;&lt;br /&gt;   &amp;lt;td&amp;gt;&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;captcha&amp;quot; size=&amp;quot;2&amp;quot;/&amp;gt; (Helps stop blog spam)&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;/pre&gt;
&lt;!--
&lt;rdf:RDF xmlns:rdf=&#034;http://www.w3.org/1999/02/22-rdf-syntax-ns#&#034;
         xmlns:dc=&#034;http://purl.org/dc/elements/1.1/&#034;
         xmlns:trackback=&#034;http://madskills.com/public/xml/rss/module/trackback/&#034;&gt;
&lt;rdf:Description
    rdf:about=&#034;http://javageek.org/2006/01/31/adding_captcha_to_your_pebble_blog.html&#034;
    dc:identifier=&#034;http://javageek.org/2006/01/31/adding_captcha_to_your_pebble_blog.html&#034;
    dc:title=&#034;Adding Captcha to your Pebble blog&#034;
    trackback:ping=&#034;http://javageek.org/addTrackBack.action?entry=1138718530887&amp;token=3626058005922596188&#034; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
        </description>
      
      
    
    
    
    <category>Web</category>
    
    <comments>http://javageek.org/2006/01/31/adding_captcha_to_your_pebble_blog.html#comments</comments>
    <guid isPermaLink="true">http://javageek.org/2006/01/31/adding_captcha_to_your_pebble_blog.html</guid>
    <pubDate>Tue, 31 Jan 2006 14:42:10 GMT</pubDate>
  </item>
  
  </channel>
</rss>

