鉴于大家对JSP,NET,JAVA类别十分关注,我们编辑小组在此为大家搜集整理了“基于JSP企业在线投票系统的设计”一文,供大家参考学习
客服咨询,网学网竭诚为您服务,本站永久域名:myeducs.cn | ||||||||
附录1 运行环境1.1硬件要求
1.2.软件要求要使用JSP,在服务器端和客户端都必须有对应的运行环境。服务器主要是Servlet兼容的Web服务器,客户端主要是浏览器。 由于Java具有跨平台的特点,所以只要能够安装JDK,就能在此安装JSP服务器。JSP服务器能够运行在目前绝大多数的操作系统上,目前在普通用户中用到的系统绝大多数为Windows系列和UNIX系列。 附录2 设计代码1.vote.jsp<%@page contentType="text/html;charset=gb2312"%> <%@page import="java.sql.*"%> <jsp:useBean id="dbBean" class="vote.DBConnect" scope="page" /> <html> <head> <title>在线投票</title> <link href="vote.css" rel="stylesheet" type="text/css"> </head> <body> <center> <h3>单选投票</h3> <hr> <form action="result.jsp" method="post"> <div align="left"> <% String sql="select * from vote where flag = 0 and optType=0 order by id desc"; ResultSet rs=dbBean.executeQuery(sql); int questionNum=0,optType,id,id1; String question,str,optContent,type; while(rs.next()){ //输出投票的主题 questionNum++; str="主题"+questionNum+":"; question=rs.getString("question"); optType=rs.getInt("optType"); id=rs.getInt("id"); out.print(str+question+"<br>"); ResultSet rs1; sql="select * from vote where flag="+id; rs1=dbBean.executeQuery(sql); out.print("<hr>"); //输出该主题的选项 while(rs1.next()){ id1=rs1.getInt("id"); optContent=rs1.getString("optContent"); if(optType==0) type="radio"; else{ type="checkbox"; } %> <input type="<%=type%>" name="vote" value="<%=id1%>"> <%=optContent%> <br> <%}%> </div> <hr> <div align="left"> <%}%> </div> <input type="submit" name="sumbit1" value="确定"> </form> <%rs.close();%> </center> </body> </html> 2.result.jsp<%@page contentType="text/html;charset=gb2312"%> <%@page import="java.sql.*"%> <html> <head> <title>投票结果</title> <link href="vote.css" rel="stylesheet" type="text/css"> </head> <body> <jsp:useBean id="dbBean" class="vote.DBConnect" scope="page" /> <h3 align="center">单选投票结果</h3> <hr> <% String sql="select * from vote order by id "; ResultSet rs=dbBean.executeQuery(sql); String id; id = request.getParameter("vote"); sql="update vote set number=number+1 where id="+id; dbBean.executeQuery(sql); ResultSet rs1,rstotal; int questionNum=0,optType,id1,number,total=0; String question,str,optContent; sql="select * from vote where flag=0 and optType=0 order by id desc"; rs=dbBean.executeQuery(sql); while(rs.next()){ questionNum++; str="主题"+questionNum+":"; question=rs.getString("question"); optType=rs.getInt("optType"); id=Integer.toString(rs.getInt("id")); out.print(str+question+"<br>"); sql="select * from vote where flag="+id; rstotal=dbBean.executeQuery(sql); //求得投票的总数 while(rstotal.next()){ number=rstotal.getInt("number"); total+=number; } sql="select * from vote where flag="+id; rs1=dbBean.executeQuery(sql); out.print("<hr>"); //输出各选项的得票数 while(rs1.next()){ id1=rs1.getInt("id"); optContent=rs1.getString("optContent"); number=rs1.getInt("number"); %> <%=optContent%> 得票数:<%=number%> <img src = bar.gif width ="<%=100*number/total%>" height = 10><br> <%}%> <hr> <div align="left"> <%}%> </div> <div align="center"><a href="index.jsp"> 返回主页 </a> </div> </body> </html>
| ||||||||
本站发布的计算机毕业设计均是完整无错的全套作品,包含开题报告+程序+论文+源代码+翻译+答辩稿PPT | ||||||||
本文选自计算机毕业设计http://myeducs.cn |