5

I cannot find any code about server-side for recaptcha v3 in java. I already added the code in my jsp file (client-side) (as you see below) but how to process it in server-side? Actually, I need server-side code in java for recaptcha v3. Thanks.

<head>
<script
    src="https://www.google.com/recaptcha/api.js?render=MySiteKey"></script>
</head>

<form>
   <input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response"> 
   <input type="hidden" name="action" value="validate_captcha">
</form>
<script>
    grecaptcha.ready(function() {
    grecaptcha.execute('MySiteKey', {
        action : 'validate_captcha'
    }).then(function(token) {
    document.getElementById('g-recaptcha-response').value = token;
    });
});
</script>

There are some exmaple in PhP such as here, but I need for java.

Sami
  • 109
  • 2
  • 6
  • 2
    You can find an example in codelabs section https://codelabs.developers.google.com/codelabs/reCAPTCHA/index.html#3 – karthick Aug 29 '19 at 18:59
  • Thanks for your useful link. In its [next step](https://codelabs.developers.google.com/codelabs/reCAPTCHA/index.html#4) I try to use the code in FeedbackServlet.java, but I can not understand what is **addParam** in _performRecaptchaSiteVerify_ function. Should I implement it myself? – Sami Aug 29 '19 at 19:34
  • 2
    You can check the codelabs git repo https://github.com/googlecodelabs/recaptcha-codelab/blob/master/final/src/main/java/com/example/feedback/FeedbackServlet.java – karthick Aug 29 '19 at 20:22
  • @karthick. Thanks - your comment helped me! You should post it as an answer! – gordon613 Jan 26 '21 at 17:11

0 Answers0