Getting information from servlet created html

Posted by user541597 on Stack Overflow See other posts from Stack Overflow or by user541597
Published on 2011-03-12T03:36:44Z Indexed on 2012/11/14 5:00 UTC
Read the original article Hit count: 171

Filed under:
|
|

I have a servlet that creates an html text box and then redirects to another servlet on submit. How can I access the value of the html text box from the new servlet? I am able to access servlet variables from the new servlet but I am not aware of how to access the value of the html generated code.

thanks,

Here is the servlet that gets the text input

  public class ServletB extends HttpServlet {



    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {

        response.setContentType("text/html");

String value = System.getProperty("card");


PrintWriter out = response.getWriter();


out.println("<center><h1>Your preffered method of payment is "+value+"</h1><br />");
out.println("Please Enter Card Number<input type =\"text\" name = \"number\"/><form action=\"http://codd.cs.gsu.edu:9999/cpereyra183/servlet/ServletC\"><input type =\"submit\" value=\"Continue\" /><input type=\"button\" value=\"Cancel\" /></center>");

    }
   }}

This is the servlet the first servlet redirects to all I do is try to do is output the text input

  public class ServletC extends HttpServlet {



    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {

        response.setContentType("text/html");

String value = System.getProperty("card");


PrintWriter out = response.getWriter();

out.println(request.getParameter("number")); 
    }
    }

© Stack Overflow or respective owner

Related posts about java

Related posts about html