pk1986 / recaptcha4j

Automatically exported from code.google.com/p/recaptcha4j
0 stars 0 forks source link

Http status error 500 - #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The report shows:

1. Need the source for java.net.URLEncoder.encode and 
java.net.URLEncoder.encode(Unknown Source)

2. Need this to work: 
net.tanesha.recaptcha.ReCaptchaImpl.checkAnswer(ReCaptchaImpl.java:63)

3. The captcha method is added in this servlet: 
com.Controllers.AddNewServlet.processRequest(AddNewServlet.java:52)

4. doPost is connected to the processRequest method in the servlet: 
com.Controllers.AddNewServlet.doPost(AddNewServlet.java:72)

5. Related errors: javax.servlet.http.HttpServlet.service(HttpServlet.java:646),
javax.servlet.http.HttpServlet.service(HttpServlet.java:727),
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

I pasted the code for reCaptcha on a method in my servlet like this:

AddNewServlet.java,

protected void processRequest(HttpServletRequest request, HttpServletResponse 
response)
            throws ServletException, IOException {
        Employee emp = new Employee();
        emp.setEmpId(Integer.parseInt(request.getParameter("empId")));
        emp.setName(request.getParameter("empName"));
        emp.setPhone(request.getParameter("phone"));
        emp.setEmail(request.getParameter("email"));
        emp.setSalary(Float.parseFloat(request.getParameter("salary")));
        emp.setDesignation(request.getParameter("designation"));
        EmployeeBean eb = new EmployeeBean();
        eb.addNew(emp);
       // response.sendRedirect("empView.jsp");
     // create recaptcha without <noscript> tags

        ReCaptcha captcha = ReCaptchaFactory.newReCaptcha("6Lct4AETAAAAAEli1aSo3ywkzorqd2Trm-expILj", "6Lct4AETAAAAAPW4aGJ7HioFcbA_kxwOqEK9L8v6", false);
        String captchaScript = captcha.createRecaptchaHtml(request.getParameter("error"), null);
        System.out.print(captchaScript);

        ReCaptchaResponse RspCap = captcha.checkAnswer(request.getRemoteAddr(), request.getParameter("/empAddNew.jsp"), request.getParameter("/empView.jsp"));
        if (RspCap.isValid()) {
            response.sendRedirect("empView.jsp");
    }
    else {
            System.out.println("You're out of my machine!");
    }

    }

protected void doGet(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, IOException {
        processRequest(request, response);
    }

Original issue reported on code.google.com by kitade96...@gmail.com on 12 Feb 2015 at 11:15

GoogleCodeExporter commented 9 years ago
I inherited a project that depended on this library.  When we needed to turn on 
the feature, it didn't work.  So with a site on fire, I clicked the "Export to 
Github" to port it to 2.0.

Want to help fix issues they've seen in this generation help social code 
open-source?  Check out my first commits 
https://github.com/peoplemerge/recaptcha4j (tests currently broken so not safe 
for prod yet... unless your site is on fire like mine was)

Original comment by d...@delicious.com on 24 Mar 2015 at 5:49