Skip to main content
Level 2
Dec 29, 2015 9:29 PM UTC
Solved

reCaptcha on CQ5.6.1 Page

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.
Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
Level 10
Dec 30, 2015 4:32 AM UTC

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
Dec 29, 2015 11:52 PM UTC

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.

Translate
RajyAuthor
Level 2
Dec 30, 2015 12:41 AM UTC

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

Translate
Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
Level 10
Dec 30, 2015 4:32 AM UTC

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

Translate