-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.jsp
More file actions
69 lines (62 loc) · 2.06 KB
/
view.jsp
File metadata and controls
69 lines (62 loc) · 2.06 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
<%@ page import="java.sql.*" %>
<html>
<head>
<title> Student Management System </title>
<link rel="stylesheet" href="mystyle.css"/>
</head>
<body>
<center>
<h1> View records of the student </h1>
<%
String un = (String) session.getAttribute("un");
if (un == null) {
response.sendRedirect("index.jsp");
}
%>
<table border="5" style="width: 60%; margin-top: 20px; margin-bottom: 20px;">
<tr>
<th style="padding: 10px;"> Rno </th>
<th style="padding: 10px;"> Name </th>
<th style="padding: 10px;"> Marks </th>
</tr>
<%
try
{
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/sms_19july23";
Connection con = DriverManager.getConnection(url, "root", "amishaka");
String sql = "SELECT rno, name, marks FROM sms";
PreparedStatement pst = con.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
while(rs.next()) {
%>
<tr style="text-align:center;">
<td style="padding: 10px;"> <%= rs.getString(1) %> </td>
<td style="padding: 10px;"> <%= rs.getString(2) %> </td>
<td style="padding: 10px;"> <%= rs.getString(3) %> </td>
</tr>
<% }
con.close();
}
catch(SQLException e)
{
out.println("sql issue " + e);
}
catch(ClassNotFoundException e)
{
out.println("Class not found: " + e);
}
%>
</table>
<br><br>
<form method="POST">
<button class="login-button" type="submit" name="btn">Back</button>
</form>
<br><br><br>
<% if (request.getParameter("btn") != null) {
response.sendRedirect("sms.jsp");
return;
} %>
</center>
</body>
</html>