I created register.jsp file and a corresponding java RegisterCommand class. Inside it I tried to organise the logic, however when users types their credentials, they don't show up in my Postgres DB
String userEmail = req.getParameter("userEmail");
String userPassword = req.getParameter("userPassword");
try {
Class.forName("org.postgresql.Driver");// Load Drivers for DB
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "postgres")) {
PreparedStatement statement = connection.prepareStatement(SQL_ADD_USER);
statement.setString(1, userEmail);
statement.setString(2, userPassword);
statement.executeUpdate();
} catch (SQLException exception) {
throw new RuntimeException("add user failed", exception);
}
CommandUtil.goToPage(req, resp, "/WEB-INF/view/register.jsp");