Advertisement
Guest User

Untitled

a guest
Feb 25th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <html>
  2. <body>
  3. <form method="post" action="login.jsp">
  4. Username:
  5. <br></br>
  6. <input type="text" name="username" size="20"></input>
  7. <br></br>
  8. Password:
  9. <br></br>
  10. <input type="password" name="password" size="20"></input>
  11. <br></br>
  12. <input type="submit"></input>
  13. </form>
  14. </body>
  15. </html>
  16.  
  17. <jsp:useBean id="usercontrol" class="usercontrol.Login" scope="session"/>
  18. <jsp:setProperty name="usercontrol" property="*"/>
  19. <html>
  20. <body>
  21. <center>
  22. <% if(false.equals(usercontrol.incorrect())) {
  23. out.println("Welcome");
  24. } else {
  25. out.println("Incorrect login");
  26. session.invalidate();
  27. }
  28. %>
  29. <br></br>
  30. <a href="/">Back</a>
  31. </center>
  32. </body>
  33. </html>
  34.  
  35. package usercontrol;
  36.  
  37. import java.util.Scanner;
  38.  
  39. import java.io.*;
  40.  
  41. public class Login {
  42. String username;
  43. String password;
  44. boolean incorrect = true;
  45.  
  46. public void checkUsername(String input) {
  47. username = input;
  48. }
  49.  
  50. public void checkPassword(String input) {
  51. password = input;
  52. login();
  53. }
  54.  
  55. void login() {
  56. try {
  57. Scanner login = new Scanner(new File(username + ".swwf"));
  58. if (password.equals(login.nextLine())) {
  59. incorrect = false;
  60. } else {
  61. incorrect = true;
  62. }
  63. login.close();
  64. } catch (FileNotFoundException fnf) {
  65. incorrect = true;
  66. }
  67. }
  68.  
  69. public boolean incorrect() {
  70. return incorrect;
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement