title: Java Servlets & Tomcat:The origin server did not find a current representation for the target resource or is not willing to disclose that one exists
body: <p>I know previous questions have been asked, can't find the right solution...</p>
  
  <p>I'm trying to create a login page. I've already have a working registration page, but my login page shows this error: <a href="https://imgur.com/a/dOGmG" rel="nofollow noreferrer">https://imgur.com/a/dOGmG</a></p>
  
  <p>The .jsp works fine- My login page appears, shows a textbox for username and password, and the button to login. But when I type in the credentials (both correct and wrong), I get the error shown in the imgur above.</p>
  
  <h2>Here is my code:</h2>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;Registration&lt;/display-name&gt;
  
      &lt;servlet&gt;
      &lt;servlet-name&gt;reg&lt;/servlet-name&gt;
      &lt;servlet-class&gt;jdbc.Registration&lt;/servlet-class&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;reg&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/regServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
      &lt;servlet&gt;
      &lt;servlet-name&gt;login&lt;/servlet-name&gt;
      &lt;servlet-class&gt;jdbc.Login&lt;/servlet-class&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;login&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/loginServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <h2>    </h2>
  
  <p>Login.java (Servlet)</p>
  
  <pre><code>@WebServlet("/Login")
  public class Login extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      public Login() {
          super();
  
      }
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      }
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  try {
              String name = request.getParameter("user");
              String password = request.getParameter("password");
              String dbName = null;
              String dbPassword = null;
              String sql = "select * from users where username=? and password=?";
              Class.forName("com.mysql.jdbc.Driver");
              Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee", "root","");
              PreparedStatement ps = conn.prepareStatement(sql);
              ps.setString(1, name);
              ps.setString(2, password);
              ResultSet rs = ps.executeQuery();
              PrintWriter out = response.getWriter();
              while(rs.next()) {
                  dbName = rs.getString("username");
                  dbPassword = rs.getString("password");
  
              }
              if (name.equals(dbName)&amp;&amp;password.equals(dbPassword)) {
  
                  out.println("You have successfully Logged in!");
              }
              else {
                  //response.sendRedirect("login.jsp");
                  RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
                  rd.include(request, response);
  
              }
  
          } catch (ClassNotFoundException e) {
  
              e.printStackTrace();
  
          } catch (SQLException e) {
  
              e.printStackTrace();
          }
      }
  
    }
  </code></pre>
  
  <hr>
  
  <p>Login.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Login&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div align="center"&gt;
  &lt;form action="Login" method="post"&gt;
  Username: &lt;input type="text" name="user" required="required"&gt;
  Password: &lt;input type="password" name="password" required="required"&gt;
  &lt;input type="submit" value="LOGIN"&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <h2>    </h2>
  
  <p>MySQL database</p>
  
  <p><a href="https://imgur.com/a/WL4t6" rel="nofollow noreferrer">https://imgur.com/a/WL4t6</a></p>
  
  <p>Database name is "employee"
  Table name is "users"</p>