0

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!! :)

3
Contributors
3
Replies
18
Views
6 Years
Discussion Span
Last Post by shadia.mohamed.9_1
0
<% 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.
");
}
}
%>

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

0

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..

-2

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.

Edited by peter_budo: Please use English

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.