protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = request.getParameter("email"); PrintWriter out = response.getWriter(); boolean isEmailValid=false; try { Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/users", "root", "root"); PreparedStatement pst = conn.prepareStatement("Select user_email from users where user_email=? "); pst.setString(1, email); ResultSet rs = pst.executeQuery(); HttpSession session = request.getSession(false); if (rs.next()) { if (rs.getString("user_email").equals(email)) { isEmailValid=true; } }if(isEmailValid){ session.setAttribute("Email", email); response.sendRedirect("Password.jsp"); }else response.sendRedirect("ErrorPage.jsp"); } catch (ClassNotFoundException | SQLException e) { Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, e); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)