reCaptcha on CQ5.6.1 Page | Community
Skip to main content
Level 2
December 29, 2015
Solved

reCaptcha on CQ5.6.1 Page

  • December 29, 2015
  • 3 replies
  • 1399 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jitendra_S_Toma

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

3 replies

smacdonald2008
Level 10
December 29, 2015

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.

RajyAuthor
Level 2
December 30, 2015

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

Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
Level 10
December 30, 2015

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