title: Get textfield string input from html file to process/use in java class
body: <p>Okay, I have no idea about what I am doing exactly but I am trying to understand it through sample programs and snippets. To be clear, my concepts are missing. So I might be having an error which is very obvious (not to me).</p>
  
  <p>I am creating a simple username-password field on a localhost and need to be able to use the textfield inputs to match them. My page shows the buttons and fields properly(index.htm in WEB-INF) but my java class needs to get the string values. I get it that form actions need URL but how can I send it to my java clasS?
  I tried using request.getParamater("id") but it says no attached doc.</p>
  
  <p>below is the html part</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;&lt;title&gt; Multi Factor Authentication Prototype &lt;/title&gt;
  &lt;link rel="stylesheet"
    href="./css/styles.css"
    type="text/css"/&gt;
  &lt;/head&gt;
  
  
  &lt;body&gt;
  &lt;table class="title"&gt;
    &lt;tr&gt;&lt;th&gt;Multi-factor Authentication, level 1 prototype &lt;/th&gt;&lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;p/&gt;
  &lt;fieldset&gt;
  &lt;form name="mfa1" action="check" method="post"&gt;
  &lt;legend&gt; Login &lt;/legend&gt; &lt;ul&gt; &lt;br /&gt;
  Username : &lt;input title="Please Enter the Username" id="uname" name="uname" type="text" size="20" /&gt;&lt;br /&gt;
  &lt;br /&gt;
  Password : &lt;input title="Please Enter your password" id="pwd" name="pwd" type="password" size="20" /&gt;&lt;br /&gt;
  &lt;br /&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>here is java class. It says no java doc referred in request field and yes, doesn't display anything.</p>
  
  <pre><code>package test;
  
  import java.io.*;
  
  import javax.servlet.*;
  import javax.servlet.annotation.*;
  import javax.servlet.http.*;
  
  import java.lang.*;
  
  @WebServlet("/check")
  
  public class TestServlet extends HttpServlet{
  
  
  @Override
    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws ServletException, IOException {
      response.setContentType("text/html");
      String un = request.getParameter("uname");
      PrintWriter out = response.getWriter();
      out.println
        ("&lt;!DOCTYPE html&gt;\n" +
         "&lt;html&gt;\n" +
         "&lt;head&gt;&lt;title&gt;tuiy&lt;/title&gt;&lt;/head&gt;\n" +
         "&lt;body bgcolor=\"#fdf5e6\"&gt;\n" +
         "&lt;h1&gt;"+un+"&lt;/h1&gt;\n" +
         "\n" +
         "&lt;/body&gt;&lt;/html&gt;");
  
  
  }
  }
  </code></pre>
  
  <p>or is there a way to insert if/else clauses and various functions in the same dcument? I would really prefer if you could help me point out the way to get the parameters in java.</p>