Expand my Community achievements bar.

SOLVED

reCaptcha on CQ5.6.1 Page

Avatar

Level 2

Hi

I'm trying to use reCaptcha on one of CQ5.6.1 page. It is working fine on local environment(localhost) but not working on Dev/QA servers. I'm using servlet to validate. My servlet code is

protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
            throws ServletException, IOException {

           String secretParameter = "<My Key>";
           String recap = request.getParameter("g-recaptcha-response");
           PrintWriter writer = response.getWriter();
           StringBuilder nsb = new StringBuilder();           

           //Generate URL
           nsb.append("https://www.google.com/recaptcha/api/siteverify?secret=");
           nsb.append(secretParameter);
           nsb.append("&response=");
           nsb.append(recap);
           nsb.append("&remoteip=");
           nsb.append(request.getRemoteAddr());
           
           .
           .
           .
           }

Our Dev\QA domains are registered with the reCaptcha API keys. I found that 'request.getParameter("g-recaptcha-response")' is returning null on QA/Dev environments but on the localhost it is valid.

Any thoughts/help on the reCaptcha not being work on Dev/QA environments?

Thanks in advance for your help.

YRJ

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi YRJ,

if you are getting 'request.getParameter("g-recaptcha-response")' null then the first thing to check the HTTP servlet call and check the parameters. 

Another thing to verify is html form (captcha field name etc.). Let me know what are the findings on above two points?.

--

jitendra

View solution in original post

3 Replies

Avatar

Level 10

Are you seeing any log messages that explain this. If it works on Dev Environment and not on the others - it looks like there is something in the other environments that are interfering with the functionality.

Avatar

Level 2

No information on log messages Scott! Yeah something is blocking on the Dev/QA environments but i have no clue yet.

Avatar

Correct answer by
Level 9

Hi YRJ,

if you are getting 'request.getParameter("g-recaptcha-response")' null then the first thing to check the HTTP servlet call and check the parameters. 

Another thing to verify is html form (captcha field name etc.). Let me know what are the findings on above two points?.

--

jitendra