How to use reCAPTCHA Ver 2 with Java?

I am trying to implement reCAPTCHA ver 2 in my Java web application. To check the user's response, I need to get the value g-recaptcha-response

that reCAPTCHA is sending to my server, as per the tutorials here . But Java does not allow variable names with hyphens in them. How to get this value?

+3


source to share


1 answer


You don't need a named variable g-recaptcha-response

. This is the parameter name in the HTTP POST request. You just extract the parameter value from the request and store it in a Java variable ... whose name is what you want.

 String str = request.getParameter("g-recaptcha-response");

      



Here are the javadocs for the class ServletRequest

.

+6


source







All Articles