Skip to content

Instantly share code, notes, and snippets.

@madan712
Created February 17, 2013 18:21
Show Gist options
  • Save madan712/4972642 to your computer and use it in GitHub Desktop.
Save madan712/4972642 to your computer and use it in GitHub Desktop.
JSP example - Google Recaptcha validation using jquery (AJAX)
<%@ page import="net.tanesha.recaptcha.ReCaptchaImpl,net.tanesha.recaptcha.ReCaptchaResponse" %><%
ReCaptchaImpl reCaptcha = new ReCaptchaImpl();
reCaptcha.setPrivateKey("your_private_key");
String remoteip = request.getParameter("remoteip");
String challenge = request.getParameter("challenge");
String res = request.getParameter("response");
ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteip, challenge, res);
if (reCaptchaResponse.isValid()) {
out.print("true");
} else {
out.print("false");
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment