-
Notifications
You must be signed in to change notification settings - Fork 0
/
trans.jsp
88 lines (59 loc) · 1.65 KB
/
trans.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
<%@ page
language="java"
import="java.sql.*,java.io.*"
%>
<%String pg=null;
String lg = (String)session.getAttribute("log");
String typ = (String)session.getAttribute("type");
RequestDispatcher ri;
if(lg == null ){
pg="err.jsp?msg=You are not Autherized to Access this page";
}
else if(typ == null ){
pg="err.jsp?msg=You are not Autherized to Access this page";
}
%>
<%
if(pg!=null)
{
ri = request.getRequestDispatcher(pg);
ri.forward(request,response);
}
String id = "";
id = session.getAttribute("id").toString();
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://127.0.0.1/bank";
Connection con=DriverManager.getConnection(url,"root","root");
Statement st=con.createStatement();
PreparedStatement pst;
if(type.equals("true"))
{
pst=con.prepareStatement("Select * from transaction");
}
else{
pst=con.prepareStatement("Select * from transaction where id=?");
pst.setString(1,id);
}
ResultSet rs = pst.executeQuery();
int sum=0;
while(rs.next())
{
sum++;
String name = rs.getString("name");
String date = rs.getString("date");
String desc = rs.getString("des");
int amount = rs.getInt("amount");
int tno = rs.getInt("tno");
%>
<tr>
<td><%= tno %></td>
<td><%= desc %></td>
<td><%= amount %></td>
<td><%= name %></td>
<td><%= date %></td>
</tr>
<%
}
if(sum==0)
out.println("<div style='display:flex;justify-content: center;color:red;margin:auto;'> <h3>No Transactions Found!"+id+"</h3></div>");
%>