title: How to call another html page java servlets
body: <p>hello i have simple login project using java servlets. i have <em>index.html</em> main page, 2 servlets first <em>Login.java</em> servlet serving index.html, second <em>UserInfo.java</em> servlet i want to be redirected to when submit button is pressed and jquery file with method which posts entered values to Login.java servlet. when i press login button nothing happens. here are source codes</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>Username:&lt;input type="text" id="username_field" value="" class="round_border"/&gt;
  Password:&lt;input type="password" id="password_field" value="" class="round_border"/&gt;
  &lt;input onclick="login()" type="submit" value="Submit" id="login_button" class="btn" /&gt;
  </code></pre>
  
  <p><strong>login.js</strong></p>
  
  <pre><code>function login(){
  
  
      var username = document.getElementById("username_field");
      var password = document.getElementById("password_field");
  
      var params = {
          username: username.value, 
          password: password.value
      };
  
  
      $.post("Login", params, function(data){alert(data);}
              );
  }
  </code></pre>
  
  <p><strong>Login.java</strong></p>
  
  <pre><code>    RequestDispatcher requestDispatcher  = request.getRequestDispatcher("UserInfo");
      requestDispatcher.forward(request, response);
  </code></pre>
  
  <p><strong>UserInfo.java</strong></p>
  
  <pre><code>try (PrintWriter out = response.getWriter()) {
  
              out.println("&lt;!DOCTYPE html&gt;");
              out.println("&lt;html&gt;");
              out.println("&lt;head&gt;");
              out.println("&lt;title&gt;Servlet UserInfo&lt;/title&gt;");            
              out.println("&lt;/head&gt;");
              out.println("&lt;body&gt;");
              out.println("&lt;h1&gt;Servlet UserInfo at " + request.getContextPath() + "&lt;/h1&gt;");
              out.println("&lt;/body&gt;");
              out.println("&lt;/html&gt;");
          }
  </code></pre>