Guest User

Untitled

a guest
Aug 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Login Page Error
  2. <h:outputText value="ENTER USERNAME" ></h:outputText>
  3. <p:inputText value="#{treeBean.username}" id="user"></p:inputText>
  4. <h:outputText value="ENTER PASSWORD" ></h:outputText>
  5. <p:inputText value="#{treeBean.userpass}" id="pass"></p:inputText>
  6. <p:commandButton value="GO" action="#{treeBean.checkuser}" onclick="redirect()"></p:commandButton>
  7. <script type="text/javascript">
  8. function redirect()
  9. {
  10. window.location="/arcpage/arc.jsf";
  11. }
  12. </script>
  13.  
  14. public void checkuser()
  15. {
  16. Connection con=null;
  17. try
  18. {
  19. Class.forName("com.mysql.jdbc.Driver");
  20. con=DriverManager.getConnection("jdbc:mysql://localhost:3306/", "root", "root");
  21. try
  22. {
  23. st.executeUpdate("USE ARCPAGE");
  24. String update="SELECT * FROM USER WHERE USER_NAME=? AND USER_PASS=?";
  25. PreparedStatement prest=con.prepareStatement(update);
  26. prest.setString(1,username);
  27. prest.setString(2,userpass);
  28. ResultSet rs=prest.executeQuery();
  29. if(rs.next()==false)
  30. {
  31. check="false";
  32. }
  33. else
  34. {
  35. check="true";
  36. }
  37. }}}
  38.  
  39. <script type="text/javascript">
  40. if(check!="true")
  41. {
  42. window.location="/arcpage/login.jsf";
  43. }
  44. </script>
  45. <Main Page Content>
  46.  
  47. <p:commandButton value="GO" action="#{treeBean.checkuser}" />
  48.  
  49. public String checkuser() {
  50. User user = userService.find(username, password);
  51.  
  52. if (user == null) {
  53. return "login";
  54. } else {
  55. return "arc";
  56. }
  57. }
Add Comment
Please, Sign In to add comment