Advertisement
Guest User

Untitled

a guest
Jun 15th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  2. <%@ page import="java.sql.*" %>
  3. <%
  4. String name,password;
  5. Connection con;
  6. Statement stmt;
  7. ResultSet rs;
  8. %>
  9.  
  10. <%
  11.  
  12. name=request.getParameter("uname");
  13. password=request.getParameter("pwd");
  14.  
  15.  
  16. try
  17. {
  18. rs=null;
  19. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  20. con=DriverManager.getConnection("Jdbc:Odbc:ERP");
  21. stmt=con.createStatement();
  22.  
  23. rs=stmt.executeQuery("select * from erplogin where name='" + name + "' and password='" + password + "'");
  24.  
  25. if (rs.next()){
  26.  
  27. String auth = rs.getString("name");
  28. System.out.println("-----------------getting auth"+auth);
  29. session=request.getSession();
  30. session.setAttribute("uname",name);
  31. session.setAttribute("pwd",password);
  32. response.sendRedirect("./MyAccount.jsp");
  33. session.setAttribute("auth",new String(auth));
  34.  
  35. }
  36. else{
  37.  
  38. response.sendRedirect("./error/accountError.jsp");
  39. }
  40.  
  41. }
  42. catch(Exception ee)
  43. {
  44. out.println(ee.getMessage());
  45. }
  46. %>
  47.  
  48. <%@page contentType="text/html"%>
  49. <%@page pageEncoding="UTF-8"%>
  50. <%@page import="java.io.*,java.util.*,java.sql.*"%>
  51. <%!
  52. String name="",password="";
  53. Connection con;
  54. Statement stmt;
  55. ResultSet rs=null;
  56. int i=0,auth=-1;
  57. String PageName="";
  58. %>
  59.  
  60. <%
  61.  
  62. try{
  63. name=(String)session.getAttribute("uname");
  64. auth=((Integer)session.getAttribute("auth")).intValue();
  65. System.out.println("---Authentication--"+auth);
  66. if(name.equals(null)||name.equals("")||name.equals(" "))
  67. response.sendRedirect("./error/accountError.jsp");
  68. }catch(Exception e){
  69. response.sendRedirect("./error/accountError.jsp");
  70. }
  71. try{
  72. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  73. con=DriverManager.getConnection("Jdbc:Odbc:ERP");
  74. stmt=con.createStatement();
  75. rs=stmt.executeQuery("Select count(*) from Messages where name='"+name+"'");
  76.  
  77. while(rs.next()){
  78. i = rs.getInt(1);
  79. }
  80. rs.close();
  81.  
  82. rs = stmt.executeQuery("select name from templates where username='"+name+"'");
  83. while(rs.next()){
  84. PageName = rs.getString(1);
  85. }
  86.  
  87. rs.close();
  88. con.close();
  89. }catch(Exception ex){
  90. }
  91. %>
  92.  
  93. try{
  94. name=(String)session.getAttribute("uname");
  95. auth=((Integer)session.getAttribute("auth")).intValue();
  96. System.out.println("---Authentication--"+auth);
  97. if(name.equals(null)||name.equals("")||name.equals(" "))
  98. response.sendRedirect("./error/accountError.jsp");
  99. }catch(Exception e){
  100. response.sendRedirect("./error/accountError.jsp");
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement