Hello, I need to create a log in MVC system, where depending if the user exists in database or not controller redirects to success.jsp with all user details or retry.jsp if the user is invalid.

Here is the code I have and it is not working:
LoginPage.jsp
<html>
    <head>
        <title>Login Page</title>
    </head>
 
    <body>
 
        <br>
 
        <form  action="controller.jsp "    method = "post" >
 
                Please enter your username
                <input type="text" name="usernameU"/><br>
 
		Please enter your password
                <input type="password" name="passwordP"/>
 
                <input type="submit"name="submit" value="Login">
 
        </form>
 
    </body>
 
</html>

controller.jsp
<%@ page import="java.util.*" %>
<jsp:useBean id="idHandler" class="foo.Login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>
 
<%
   if (idHandler.authenticate()) {
%>
<jsp:forward page="success.jsp"/>
<%
   }  else {
%>
<jsp:forward page="retry.jsp"/>
<%
   }
%>
Login.java
package foo;
 
import java.sql.*;
 
 
public class Login {
 
    private String usernameU = "";
    private String passwordP = "";
 
    public Login() {
    }
 
    public void setUsername(String usernameU) {
        this.usernameU = usernameU;
    }
 
    public void setPassword(String passwordP) {
        this.passwordP = passwordP;
    }
 
    public boolean authenticate(String usernameU,
            String passwordP) {
        String query = "select * from Users;";
        String dbUserName = "";
        String dbFirstName = "";
        String dbLastName = "";
        String DbPassword = "";
        String dbAddress = "";
        String dbDOB = "";
 
        try {
 
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://localhost/User";
            String username = "root";
            String password = "oksana";
 
            Connection connection = DriverManager.getConnection(url, username, password);
 
            Statement stat = connection.createStatement();
            ResultSet rst = stat.executeQuery(query);
            while (rst.next()) {
                dbUserName = rst.getString("UserName");
                dbFirstName = rst.getString("FirstName");
                dbLastName = rst.getString("LastName");
                DbPassword = rst.getString("Password");
                dbAddress = rst.getString("Address");
                dbDOB = rst.getString("DateOfBirth");
 
 
                if (usernameU.equals(dbUserName)
                        && passwordP.equals(DbPassword)) {
 
                    break;
                }
 
 
            }
            return true;
        } catch (Exception e) {
 
            e.printStackTrace();
            return false;
        }
    }
}
I am very new to J2EE and it is very much possible that the solution I have is bad. I will be grateful for any kind of advice or help with the code.