Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Login(HttpServletRequest request, HttpServletResponse response){
- try{
- String username = request.getParameter("username");
- String password = request.getParameter("password");
- Class.forName("com.mysql.jdbc.Driver"); // MySQL database connection
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Breakout?" + "user=root&password=");
- PreparedStatement pst = conn.prepareStatement("select username,password from Users where username=?");
- pst.setString(1, username);
- ResultSet rs = pst.executeQuery();
- while(rs.next()){
- if(BCrypt.checkpw(password,rs.getString("password"))){
- System.out.println(username +" ingelogd");
- response.sendRedirect("index.jsp");
- //request.getRequestDispatcher(request.getContextPath()+"/assets/pages/game.jsp").forward(request,response);
- } else {
- System.out.println("INLOGGEN MISLUKT");
- response.sendRedirect("assets/pages/login.jsp?login=error");
- //request.getRequestDispatcher("/assets/pages/login.jsp?login=error").forward(request,response);
- }
- }
- }
- catch(Exception e){
- System.out.println("Something went wrong !! Please try again");
- System.out.println(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement