Advertisement
Guest User

ex2

a guest
Jul 6th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <%--
  2. Document : List_Person
  3. Created on : 27-mag-2016, 9.15.54
  4. Author : Luigi
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  12. <title>JSP Page</title>
  13. </head>
  14. <body>
  15. <%@ page import = "java.sql.*" %>
  16. <%
  17. String st1;
  18. String st2;
  19. String ritorno1;
  20. String ritorno2;
  21.  
  22. Class.forName("oracle.jdbc.driver.OracleDriver");
  23. Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@Luigi-PC:1521:xe","esame","ciao");
  24. Statement stmt = conn.createStatement();
  25. String sql="select username,pass from accesso";
  26. ResultSet rs = stmt.executeQuery(sql);
  27. ritorno1=request.getParameter("message");
  28. ritorno2=request.getParameter("message2");
  29.  
  30. try
  31. {
  32. if(rs!=null)
  33. {
  34. %>
  35.  
  36. <%
  37. while(rs.next())
  38. {
  39.  
  40. st1=rs.getString("username");
  41. st2=rs.getString("pass");
  42.  
  43. int result_1 = st1.compareTo(ritorno1);
  44. int result_2 = st2.compareTo(ritorno2);
  45.  
  46. if((result_1==0) && (result_2==0)){
  47. %>
  48.  
  49. <jsp:include page="menu.jsp" />
  50. <%
  51. }else{
  52. %>
  53. <jsp:include page="index.jsp" />
  54. <%
  55. }
  56.  
  57.  
  58.  
  59. }
  60. }
  61. }
  62. catch(SQLException e)
  63. {
  64. e.printStackTrace();
  65. }
  66. stmt.close();
  67. rs.close();
  68. conn.close();
  69. stmt=null;
  70. rs=null;
  71. conn=null;
  72. %>
  73.  
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement