-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.jsp
100 lines (96 loc) · 2.8 KB
/
view.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
<%@ page language="java" import="java.sql.*,java.util.*,java.text.*"%>
<html>
<head>
<title>View Record</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<%
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"
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>
</head>
<body class="container">
<%
String strId = request.getParameter("id");
int id = Integer.parseInt(strId);
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "matpass";
String driver = "com.mysql.cj.jdbc.Driver";
try {
Class.forName(driver);
con = DriverManager.getConnection(url + db, "root", "qwerty");
try {
Statement st = con.createStatement();
String query = "SELECT id,type,purpose,pdesc,bdesc,valid FROM records WHERE id=" + id;
ResultSet rs = st.executeQuery(query);
while (rs.next()) {
%>
<input type="hidden" name="id" value="<%=request.getParameter("id")%>">
<h5 align="center"><b><i>VIEW RECORD</i></b></h5>
<table class="striped centered highlight">
<tr>
<td><h6>
<b>Type: </b>
</h6></td>
<td><h6><%=rs.getString("type")%></h6></td>
</tr>
<tr>
<td><h6>
<b>Purpose</b>
</h6></td>
<td><h6><%=rs.getString("purpose")%></h6></td>
</tr>
<tr>
<td><h6>
<b>Purpose Description</b>
</h6></td>
<td><p><%=rs.getString("pdesc")%></p></td>
</tr>
<tr>
<td><h6>
<b>Bearer Details</b>
</h6></td>
<td><p><%=rs.getString("bdesc")%></p></td>
</tr>
<tr>
<td><h6>
<b>Valid</b>
</h6></td>
<td><p><%=rs.getString("valid")%></p></td>
</tr>
</table>
<%
}
rs.close();
con.close();
} catch (SQLException ex) {
System.out.println("SQL statement is not executed!");
ex.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
%>
<%
out.println("<br>");
out.println("<a href='ListRecords.jsp'> RETURN TO MAIN PAGE </a>");
%>
</body>
</html>