-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.jsp
More file actions
97 lines (94 loc) · 2.47 KB
/
view.jsp
File metadata and controls
97 lines (94 loc) · 2.47 KB
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
<%@ page import="java.sql.*" %>
<html>
<head>
<title>FeedBack Management System</title>
<style>
body {
background-color: #f5f5f5;
font-family: Arial, sans-serif;
}
.nav {
background-color: #007bff;
padding: 10px;
margin-bottom: 20px;
}
.nav a {
color: white;
text-decoration: none;
margin: 0 10px;
}
.nav a:hover {
text-decoration: underline;
}
h1 {
text-align: center;
color: #333;
}
table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
}
th {
background-color: #007bff;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
</style>
</head>
<body>
<center>
<div class="nav">
<a href="home.jsp">Home</a>
<a href="delete.jsp">Delete your feedback</a>
</div>
<br><br/>
<h1>View Feedbacks from our Students</h1>
<%
String un = (String) session.getAttribute("un");
if (un == null) {
response.sendRedirect("index.jsp");
}
%>
<table border="5">
<tr>
<th>Name</th>
<th>Ratings</th>
<th>Query/Feedbacks</th>
</tr>
<%
try {
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://localhost:3306/feedback_app";
Connection con = DriverManager.getConnection(url, "root", "amishaka");
String sql = "SELECT name, feedback, query FROM student";
PreparedStatement pst = con.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
while (rs.next()) {
%>
<tr>
<td><%= rs.getString(1) %></td>
<td><%= rs.getString(2) %></td>
<td><%= rs.getString(3) %></td>
</tr>
<%
}
con.close();
} catch (SQLException e) {
out.println("SQL issue " + e);
}
%>
</table>
</center>
</body>
</html>