-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetchDetails.jsp
150 lines (140 loc) · 5.14 KB
/
fetchDetails.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<%--
Document : fetchDetails
Created on : Jun 21, 2017, 8:10:53 AM
Author : sreekanth kasani ')
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="table.css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Fetching</title>
</head>
<body>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.sql.DriverManager.*" %>
<%@page import="java.util.*" %>
<%
boolean permit=false;
String exportToExcel = request.getParameter("exportToExcel");
if (exportToExcel != null
&& exportToExcel.toString().equalsIgnoreCase("YES")) {
permit = true;
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename="
+ "excel.xls");
}
%>
<%
String q = null;
if(!permit){
q = request.getParameter("q");
session.setAttribute("status",q);
}else{
q = session.getAttribute("status").toString();
}
String[] str = q.split("\\s+");
ArrayList<String> columns = null;
ResultSetMetaData metadata;
int columnCount = 0;
String columnName = null;
String post_type = (String) session.getAttribute("postType");
PreparedStatement ps;
Connection conn;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/scms", "root", "root");
Statement st = conn.createStatement();
%>
<%
try {
rs = st.executeQuery(q);
metadata = rs.getMetaData();
columnCount = metadata.getColumnCount();
columns = new ArrayList<String>();
for (int i = 1; i < columnCount + 1; i++) {
columnName = metadata.getColumnName(i);
columns.add(columnName);
}
} catch (SQLException e) {
System.out.println(e);
}
%>
<div style="font-family: cursive;">
<h1> <%= str[3] %> </h1>
</div>
<%-- <%
if (rs.next()) {
%> --%>
<table style="width: 1227px;">
<thead>
<tr>
<%
for (int i = 0; i < columns.size(); i++) {
%>
<th><%String k = columns.get(i);%><%= k%> </th>
<%
}
%>
<th> </th>
</tr>
</thead>
<tbody>
<%
if(rs.next()){
do {
%>
<tr>
<%
String id = null;
for (int i = 0; i < columns.size(); i++) {
columnName = columns.get(i);
String k = rs.getString(columnName);
%>
<td><% if (columnName.equals("admission_no")){
id = k;
%>
<a href="getProfile.jsp?refno=<%=k %>"><%= k%></a>
<% }else if (columnName.equals("email") || columnName.equals("counseller_email") ) {%>
<a href="mailto:<%= k%>"><%= k%> </a>
<%} else {%>
<%= k%>
<%}%>
</td>
<%
}
%>
<td>
<a href="getProfile.jsp?refno=<%= id %>"><img src="profile_img.png" alt="P"></a>
<a href="editProfile.jsp?refno=<%= id %>"><img src="edit.png" alt="E"></a>
<a href="deleteProfile.jsp?refno=<%= id %>"><img src="delete.png" alt="D"></a>
</td>
</tr>
<%
}while(rs.next());
%>
</tbody>
</table>
<%} else {%>
<h3 style="font-family: cursive;"> no search results found </h3>
<%}%>
<center>
<footer style="
width: 1438px;
margin-left: 2px;
margin-bottom: 0px;
height: 0px;
margin-right: 111px;
padding-top: 0px;
padding-bottom: 20px;
">
<ul>
<li style="margin-right:120px; float: right; text-decoration: none;"><a href="misc.jsp?req=1">give a feedback </a> | <a href="misc.jsp?req=2"> about project</a> | <a href="misc.jsp?req=3"> Contact </a> </li>
</ul>
</footer>
</center>
</body>
</html>