⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vote.jsp

📁 机械工业出版社的《jsp2.0动态网站开发实例指南》的源代码
💻 JSP
字号:
<!--vote.jsp-->
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<html>
<head>
<title>Vote</title>
</head>
<body bgcolor=#C0C0C0>
<center>
<h1>投票 </h1>
<br>
<table width="300">
<tr>注意事项:</tr>
<tr>&nbsp;&nbsp;1.每个用户ID只能投票一次</tr>
<tr>&nbsp;&nbsp;2.可以增加其他候选人提名</tr>
<tr>&nbsp;&nbsp;&nbsp;&nbsp;投票计入新候选人得票数</tr>
</table>
<br>
<br>
<form action="dealvote.jsp" method="post" name="voteform">
<%
	try{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		Connection con=DriverManager.getConnection("jdbc:odbc:vote","","");
		Statement sql=con.createStatement();
		String condition="SELECT name FROM vote";
		ResultSet rs=sql.executeQuery(condition);
		%>
		<table width="300" border="1" height="25">
		<tr width="300" height="25">
		<td width="200">姓名</td>
		<td width="100">投他一票</td>
		</tr>
		<%
		while(rs.next()){
			String name=rs.getString(1);
			if(name!=null){
				%>
				<tr width="300" height="25">
				<td width="200"><%=name%></td>
				<td width="100"><input type="radio" name="radio" value="<%=name%>"></td>
				</tr>
				<%
			}
		}
		con.close();
	}
	catch(SQLException e ){
		out.print(e);
	}
	catch(ClassNotFoundException e){
		out.print(e);
	}
%>
</table>
<br>
提名候选人:<input type="text" name="newname">
<br>
选举人姓名:<input type="text" name="voter">
<br>
<input type="submit" name="submit" value="提交">
<input type="reset" name="reset" value="重置">
</form>
</center>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -