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
| <%@ page language="java" contentType="text/html; charset=BIG5" pageEncoding="BIG5"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="zh-tw">
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>2008恐龍展報名資料</title>
</head>
<body>
<p>2010生姿畢業旅行投票資料</p>
<%
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/dino";
Connection con = DriverManager.getConnection( url,"bioinfo", "6193");
Statement stmt = con.createStatement();
String query="SELECT SID, SName, SLoc, SComment, SDate FROM vote ORDER BY SDate";
stmt.execute(query);
ResultSet rs = stmt.getResultSet();
int num_rows=rs.getMetaData().getColumnCount();
%>
<p> <%= num_rows %> 筆投票資料</p>
<table border="1" width="100%" id="table1">
<tr>
<td>學號</td>
<td>姓名</td>
<td>選擇地點</td>
<td>投票時間</td>
<td>意見</td>
</tr>
<%
while (rs.next()) {
String SID = new String(rs.getString(1).getBytes("ISO-8859-1"), "Big5");
String SName = new String(rs.getString(2).getBytes("ISO-8859-1"), "Big5");
String SLoc = new String(rs.getString(3).getBytes("ISO-8859-1"), "Big5");
Timestamp SDate = rs.getTimestamp(5);
String SComment = new String(rs.getString(4).getBytes("ISO-8859-1"), "Big5");
%>
<tr>
<td><%=SID %></td>
<td><%=SName %></td>
<td><%=SLoc %></td>
<td><%=SDate %></td>
<td><%=SComment %>_</td>
</tr>
<%
}
%>
</table>
<hr>
投票結果
<table border="1" width="100%" id="table2">
<tr>
<%
rs.close();
query="SELECT Count(SLoc) AS SNum, SLoc FROM vote GROUP BY SLoc";
stmt.execute(query);
rs = stmt.getResultSet();
while (rs.next()) {
int SNum = rs.getInt(1);
String SLoc = new String(rs.getString(2).getBytes("ISO-8859-1"), "Big5");
%>
<td><%=SLoc %></td>
<td><%=SNum %></td>
<%
}
con.close();
%>
</tr>
</table>
</body>
</html> |
Tags: 97(上), JavaEE, 上課, 生資
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
| <%@ page language="java" contentType="text/html; charset=BIG5" pageEncoding="BIG5"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<meta http-equiv='Content-Language' content='zh-tw'>
<meta http-equiv='Content-Type' content='text/html; charset=big5'>
<title>2010生姿畢業旅行投票</title>
</head>
<%
//將表單元件的值轉成jsp變數
request.setCharacterEncoding("Big5");
String Var1 = request.getParameter("SID");
String Var2 = request.getParameter("SName");
String Var3 = request.getParameter("SCode");
String Var4 = request.getParameter("SLoc");
String Var5 = request.getParameter("SComment");
%>
<%
//將表單元件的值存入資料庫
String SID = new String(Var1.getBytes("Big5"), "ISO-8859-1");
String SName = new String(Var2.getBytes("Big5"), "ISO-8859-1");
String SCode = new String(Var3.getBytes("Big5"), "ISO-8859-1");
String SLoc = new String(Var4.getBytes("Big5"), "ISO-8859-1");
String SComment = new String(Var5.getBytes("Big5"), "ISO-8859-1");
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/dino";
Connection con = DriverManager.getConnection( url,"bioinfo", "6193");
Statement stmt = con.createStatement();
String query="INSERT INTO vote(SID, SName, SCode, SLoc, SComment) VALUES('"+SID+"', '"+SName+"', '"+SCode+"', '"+SLoc+"', '"+SComment+"')";
stmt.executeUpdate(query);
con.close();
%>
<body>
<p>2010生姿畢業旅行投票-投票完成</p>
<table border='1' width='100%' id='table1'>
<tr>
<td align=right width=200>學號</td>
<td><%= Var1 %></td>
</tr>
<tr>
<td align=right width=200>姓名</td>
<td><%= Var2 %></td>
</tr>
<tr>
<td align=right width=200>身份證末四碼</td>
<td><%= Var3 %></td>
</tr>
<tr>
<td align=right width=200>選擇地點</td>
<td><%= Var4 %></td>
</tr>
<tr>
<td align=right width=200>意見</td>
<td><%= Var5 %></td>
</tr>
</table>
<hr>
<a href='bilist.jsp'>查看報名資料</a>
</body>
</html> |
Tags: 97(上), JavaEE, 上課, 生資
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
| <%@ page language="java" contentType="text/html; charset=BIG5" pageEncoding="BIG5"%>
<%@ page import="java.sql.*" %>
<html>
<head>
<meta http-equiv='Content-Language' content='zh-tw'>
<meta http-equiv='Content-Type' content='text/html; charset=big5'>
<title>2010生姿畢業旅行投票</title>
</head>
<%
//將表單元件的值轉成jsp變數
request.setCharacterEncoding("Big5");
String Var1 = request.getParameter("SID");
String Var2 = request.getParameter("SName");
String Var3 = request.getParameter("SCode");
String Var4 = request.getParameter("SLoc");
String Var5 = request.getParameter("SComment");
%>
<%
//將表單元件的值存入資料庫
String SID = new String(Var1.getBytes("Big5"), "ISO-8859-1");
String SName = new String(Var2.getBytes("Big5"), "ISO-8859-1");
String SCode = new String(Var3.getBytes("Big5"), "ISO-8859-1");
String SLoc = new String(Var4.getBytes("Big5"), "ISO-8859-1");
String SComment = new String(Var5.getBytes("Big5"), "ISO-8859-1");
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/dino";
Connection con = DriverManager.getConnection( url,"bioinfo", "6193");
Statement stmt = con.createStatement();
String query="INSERT INTO vote(SID, SName, SCode, SLoc, SComment) VALUES('"+SID+"', '"+SName+"', '"+SCode+"', '"+SLoc+"', '"+SComment+"')";
stmt.executeUpdate(query);
con.close();
%>
<body>
<p>2010生姿畢業旅行投票-投票完成</p>
<table border='1' width='100%' id='table1'>
<tr>
<td align=right width=200>學號</td>
<td><%= Var1 %></td>
</tr>
<tr>
<td align=right width=200>姓名</td>
<td><%= Var2 %></td>
</tr>
<tr>
<td align=right width=200>身份證末四碼</td>
<td><%= Var3 %></td>
</tr>
<tr>
<td align=right width=200>選擇地點</td>
<td><%= Var4 %></td>
</tr>
<tr>
<td align=right width=200>意見</td>
<td><%= Var5 %></td>
</tr>
</table>
<hr>
<a href='bilist.jsp'>查看報名資料</a>
</body>
</html> |
Tags: 97(上), JavaEE, 上課, 生資