-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListRecords.jsp
114 lines (111 loc) · 3.45 KB
/
ListRecords.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html>
<%@ page language="java" import="java.sql.*,java.util.*,java.text.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<%
response.setHeader("Cache-Control", "no-cache"); //forces caches to obtain a new copy of the page from the origin server
response.setHeader("Cache-Control", "no-store"); //directs caches not to store the page under any circumstance
response.setDateHeader("Expires", 0); //causes the proxy cache to see the page as "stale"
response.setHeader("Pragma", "no-cache"); //HTTP 1.0 backward compatibility
String username = (String) session.getAttribute("session_user");
if (null == username) {
request.setAttribute("Error", "Session has ended. Please login.");
RequestDispatcher rd = request.getRequestDispatcher("LoginPage.jsp");
rd.forward(request, response);
}
%>
<style>
* {
padding: 2px;
}
</style>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css">
<script
src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
<body class="container">
<ul>
<li><a href="LogoutAction.jsp"
onclick="return confirm('Are you sure you want to Logout?')">Logout</a></li>
</ul>
<h6>
<i><b> Welcome User Staff Id:${sessionScope.session_user}</b></i>
</h6>
<div align="center">
<br>
<h5>
<b><i>Records</i></b>
</h5>
<table class="striped highlight centered">
<tbody>
<td><b>ID</b></td>
<td><b>TYPE</b></td>
<td><b>PURPOSE</b></td>
<td><b>PURPOSE DESCRIPTION</b></font></td>
<td><b>BEARER DETAILS</b></td>
<td></td>
<td></td>
<td></td>
<%
String DRIVER = "com.mysql.cj.jdbc.Driver";
Class.forName(DRIVER).newInstance();
Connection con = null;
ResultSet rst = null;
Statement stmt = null;
try {
String url = "jdbc:mysql://localhost:3306/matpass?user=root&password=qwerty";
int i = 1;
con = DriverManager.getConnection(url);
stmt = con.createStatement();
rst = stmt
.executeQuery("SELECT id,type,purpose,pdesc,bdesc,valid,auth,ret FROM records WHERE auth=" + 0);
while (rst.next()) {
if (i == (i / 2) * 2) {
%>
<tr>
<td><%=i%></td>
<td><%=rst.getString(2)%></td>
<td><%=rst.getString(3)%></td>
<td><%=rst.getString(4)%></td>
<td><%=rst.getString(5)%></td>
<td><a href="edit.jsp?id=<%=rst.getInt("id")%>"> Edit
Record </a></td>
<td><a href="delete.jsp?id=<%=rst.getInt("id")%>"> Delete
Record </a></td>
<td><a href="view.jsp?id=<%=rst.getInt("id")%>"> View
Record </a></td>
</tr>
<%
} else {
%>
<tr>
<td><%=i%></td>
<td><%=rst.getString(2)%></td>
<td><%=rst.getString(3)%></td>
<td><%=rst.getString(4)%></td>
<td><%=rst.getString(5)%></td>
<td><a href="edit.jsp?id=<%=rst.getInt("id")%>"> Edit
Record </a></td>
<td><a href="delete.jsp?id=<%=rst.getInt("id")%>"> Delete
Record </a></td>
<td><a href="view.jsp?id=<%=rst.getInt("id")%>"> View
Record </a></td>
</tr>
<%
}
i++;
}
rst.close();
stmt.close();
con.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
%>
</tbody>
</table>
</div>
</body>
</html>