title: Using Html form passing parameter to java file
body: <p>Passing Parameter to the Java file using Html form I couldn't run in my Tomcat server.
  Who can describe this example step by step? where shall I put .html file and where .java and . class files. I am attaching html and java file. The compiled file with .class extension I have already done! Thank you in advance!</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  &lt;title&gt;New Page 1&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;h2&gt;Login&lt;/h2&gt;
  &lt;p&gt;Please enter your username and password&lt;/p&gt;
  &lt;form method="GET" action="/htmlform/LoginServlet"&gt;
    &lt;p&gt; Username  &lt;input type="text" name="username" size="20"&gt;&lt;/p&gt;
    &lt;p&gt; Password  &lt;input type="text" name="password" size="20"&gt;&lt;/p&gt;
    &lt;p&gt;&lt;input type="submit" value="Submit" name="B1"&gt;&lt;/p&gt;
  &lt;/form&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is my LoginServlet.java file:</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  public class LoginServlet extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response)
                                     throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      String name = request.getParameter("username");
      String pass = request.getParameter("password");
      out.println("&lt;html&gt;");
      out.println("&lt;body&gt;");
      out.println("Thanks  Mr." + "  " + name + "  " + "for visiting roseindia&lt;br&gt;" );
      out.println("Now you can see your password : " + "  " + pass + "&lt;br&gt;");
      out.println("&lt;/body&gt;&lt;/html&gt;");
    }
  }
  </code></pre>