Guest User

Untitled

a guest
Apr 8th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  2.  
  3. resp.setContentType("text/html");
  4.  
  5.  
  6. String login =req.getParameter("login");
  7. String password =req.getParameter("password");
  8.  
  9.  
  10. try {
  11. Class.forName("com.mysql.jdbc.Driver");
  12. Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/steg","root","");
  13. PreparedStatement pst = conn.prepareStatement("Select * from Employe where login=? and password=?");
  14.  
  15. pst.setString(1, login);
  16. pst.setString(2, password);
  17. ResultSet rs = pst.executeQuery();
  18.  
  19.  
  20. if (rs.next()) {
  21.  
  22.  
  23. HttpSession session=req.getSession();
  24. session.setAttribute("login",login);
  25. session.setAttribute("password",password);
  26.  
  27. req.setAttribute("liste",liste);
  28. req.setAttribute(login, rs);
  29.  
  30. resp.sendRedirect("account.jsp");
  31. }
  32.  
  33. else {
  34. resp.sendRedirect("erreur.jsp");
  35. }
  36. } catch (ClassNotFoundException | SQLException e) {
  37. e.printStackTrace();
  38. }
Add Comment
Please, Sign In to add comment