Advertisement
Guest User

Untitled

a guest
Mar 29th, 2016
77
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 request, HttpServletResponse response) throws ServletException, IOException
  2. {
  3.  
  4. response.setContentType("text/html");
  5. PrintWriter out=response.getWriter();
  6.  
  7. String username=request.getParameter("username");
  8. String password=request.getParameter("password");
  9.  
  10.  
  11. if(LoginDao.validate(username, password))
  12. {
  13. out.print("you are successfully logged in!");
  14. //request.getSession().setAttribute("login", "true");
  15.  
  16.  
  17.  
  18.  
  19. }
  20.  
  21. else
  22. {
  23. out.print("Sorry, username or password error");
  24.  
  25. }
  26.  
  27. }
  28.  
  29. Class.forName("com.mysql.jdbc.Driver");
  30. conn = DriverManager.getConnection(DB_URL,USER,PASS);
  31. ps=conn.prepareStatement("select * from verify where username=? and password=? ");
  32.  
  33.  
  34.  
  35. ps.setString(1,username);
  36. ps.setString(2,password);
  37. //ps.setString(3,"yes");
  38. ResultSet rs=ps.executeQuery();
  39.  
  40.  
  41. if(rs.next())
  42. {
  43. status=true;
  44. }
  45.  
  46.  
  47. }catch(Exception e)
  48. {
  49. System.out.println(e);
  50. }
  51.  
  52. return status;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement