add.jsp
%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%>
<jsp:useBean id="db" scope="session" class="com.bean.DBBean"/>
<%
request.setCharacterEncoding("gb2312");
String str=request.getParameter("additem");
if(str!=null)
//String sql="insert into vote(item,count) values('"+additem+"',"+0+")";
db.executeUpdate("insert into vote(item,count) values('"+str+"',"+0+")");
db.close();
%>
<jsp:forward page="manage.jsp"/>
delete.jsp
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%>
<jsp:useBean id="db" scope="session" class="com.bean.DBBean"/>
<%
String delid=request.getParameter("delid");
if(delid!=null)
{
db.executeUpdate("delete from vote where id="+delid);
db.close();
}
%>
<jsp:forward page="manage.jsp"/>
index.jsp
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%>
<jsp:useBean id="db" scope="session" class="com.bean.DBBean"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>投票系统首页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body BGSOUND="E:\\MP3\\新歌试听\\汪峰 - 怒放的生命.mp3">
<center>
<h2>您最喜爱的奥斯卡获奖影片是:</h2>
<table border bordercolor="#0066FF" bgcolor="#ffffff">
<form method="post" action="vote.jsp">
<%
ResultSet rs=db.executeQuery("select * from vote");
while(rs.next())
{
out.print("<tr>");
out.print("<td><input type='radio' name='id' value='"+rs.getString("id")+"'>");
//System.out.println(""+num);
out.print(rs.getString("item"));
out.print("</td>");
}
rs.close();
db.close();
session.setMaxInactiveInterval(-1);
%>
<tr><td align="center"><input type="submit" value="投票"></td></tr>
<tr><td align="center"><a href="info.jsp">查看投票</a></td>
</table>
<p><a href="manage.jsp">投票系统维护</a>
</center>
</body>
</html>
info.jsp
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="gb2312"%>
<jsp:useBean id="db" scope="session" class="com.bean.DBBean"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'info.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">