Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setContentType("text/html");
- String login =req.getParameter("login");
- String password =req.getParameter("password");
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/steg","root","");
- PreparedStatement pst = conn.prepareStatement("Select * from Employe where login=? and password=?");
- pst.setString(1, login);
- pst.setString(2, password);
- ResultSet rs = pst.executeQuery();
- if (rs.next()) {
- HttpSession session=req.getSession();
- session.setAttribute("login",login);
- session.setAttribute("password",password);
- req.setAttribute("liste",liste);
- req.setAttribute(login, rs);
- resp.sendRedirect("account.jsp");
- }
- else {
- resp.sendRedirect("erreur.jsp");
- }
- } catch (ClassNotFoundException | SQLException e) {
- e.printStackTrace();
- }
Add Comment
Please, Sign In to add comment