HI,

I need to have a captcha in my jsp page. The captcha code is ready and it works perfectly well when the user enters the value. It reloads the same page if the captcha enterd is wrong. I need to navigate to the next page if the value is correct. The varification of wthr the user inout matches the image is done as soon as user submits the captcha. How will I add the code to navigate to the next page once the captcha is right.
My code is

<form id="id" method="post">
<div id="body-right">
<table align="right" cellspacing="15">
<tr>
<td>PLEASE TYPE THE TEXT IN THE IMAGE</td>
<tr>
<td><input type="text" name="code"  autocomplete="off"></td></tr>
<tr><td><img src="http://localhost:12957/TESTROI/CaptchaServlet"></td></tr>
<tr><td><input type="submit" value="SUBMIT"></td></tr>
</table>
<br>
<br><br>
</div>
</form>

The verification goes to a servelt wr I have implemented the servlet. Its in jsp. code follows :

<%
out.println("<div id=\"gtwo\">");
  String captcha = (String) session.getAttribute("captcha");
  String code = (String) request.getParameter("code");

  out.println("<form id=\"id\" method=\"post\" action=\"http://localhost:12957/TESTROI/index.jsp\">");

  if (captcha != null && code != null) {

    if (captcha.equals(code)) {

       
	  out.print("<p>YOU CAN CONTINUE TO THE STORE PARAMETERS PAGE!!</p>");
          
          out.println("<input type=\"submit\" value=\"STORE PARAMETERS\">");
          
          
    } else {
          out.print("<p class='alert'>WRONG ENTRY!!!    TRY AGAIN!!</p>");
          
    }

    out.println("</form>");
  }
%>

As if now I have kept a submit button which is displayed only when captcha is correct. But I need to remove this and navigate automatically to the page if the input is corect

Could anyone help?

Thanks in advance!! :)

<% String captcha = (String) session.getAttribute("captcha"); String code = (String) request.getParameter("code"); if (captcha != null && code != null) { if (captcha.equalsIgnoreCase(code)) { String url="#"; RequestDispatcher rd=request.getRequestDispatcher(url); rd.forward(request,response); } else { out.print("
The characters you entered didn't match the word verification. Please try again.
");
}
}
%>

hi.. i have no idea about JSP. But i am in a real problem as i want to create captcha in JSP i am trying from last 5 days but not get any sucess. i need it really urgent. i cant use 3rd party tool. i need hand written code if you have plz mail me kd.bhargava5@gmail.com and describe me how can i use that code..

Captcha en JSP que estoy tratando de hace 5 días, pero no obtengo ningún éxito. Necesito realmente urgente. i no puede utilizar la herramienta de 3 ª parte.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.