title: Servlet not updating value in database
body: <p>I'm trying to create a basic password reset system. I'm creating an unique token for each user, storing in database and retrieving that token value in url like: <a href="http://localhost:8080/login/reset-password.jsp?token=0d1eaa1a-869c-4f40-8437-a3cdaeddf497" rel="nofollow noreferrer">http://localhost:8080/login/reset-password.jsp?token=0d1eaa1a-869c-4f40-8437-a3cdaeddf497</a></p>
  
  <p>The problem here is that I'm trying to update the password in the database but the value isn't updated. It displays that the password is changed, but nothing happens in database. Please help.</p>
  
  <p>Here's my servlet:</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
          String password = request.getParameter("password");
          String token = request.getParameter("token");
  
  
  
                  ForgotPasswordHandler.UpdatePassword(password, token);
  
                  String message = "Password changed!";
                  request.setAttribute("message", message);
                  request.getRequestDispatcher("reset-password.jsp?token=" + token).forward(request, response);   
  
  
  
      } 
  </code></pre>
  
  <p>Here's my method in class ForgotPasswordHandler.java:</p>
  
  <pre><code>public static void UpdatePassword(String password, String token) {
  
              try
                {
  
                if (con == null){
                   System.out.println("Failed connection");
  
                }else{
  
                  PreparedStatement ps = con.prepareStatement(
                    "UPDATE user SET password = ? WHERE reset_token = ?");
  
                  ps.setString(1,password);
                  ps.setString(2,token);
  
                  ps.executeUpdate();
  
                  ps.close();
  
  
                }}
              catch (Exception e) {
                   e.printStackTrace(System.out);    
                }
  
              }
  
  </code></pre>