欢迎来到天天文库
浏览记录
ID:34723966
大小:65.18 KB
页数:5页
时间:2019-03-10
《jsp实现投票系统源码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、这是用文本文件作为存储载体的投票系统:vote.java:packagevote;importjava.io.*;importjava.util.*;publicclassvoteextendsObject{ publicStringfilePath=""; publicintn; privateFilevoteFile; privateBufferedReaderfileRead; privatePrintWriterfileWrite; publicStringsystemMessage=""; privateStringvoteStr[
2、]=newString[10]; publicintvoteNum[]=newint[10]; publicvoidcreateFile() throwsFileNotFoundException{ voteFile=newFile(filePath); if(!voteFile.exists()) { fileWrite=newPrintWriter(newFileOutputStream(filePath)); for(inti=0;i3、ln("0"); fileWrite.close(); }}publicvoidwriteFile() throwsFileNotFoundException { fileWrite=newPrintWriter(newFileOutputStream(filePath)); for(inti=0;i4、ile() throwsFileNotFoundException { fileRead=newBufferedReader(newFileReader(filePath)); for(inti=0;i5、 voteNum[i]=Integer.parseInt(voteStr[i]); } try { fileRead.close(); } catch(IOExceptiond) { systemMessage=d.toString(); } }} vote.jsp:<%@pagecontentType="text/6、html;charset=gb2312"language="java"errorPage=""%><%@pageimport="java.util.*"%><%@pageimport="java.lang.*"%><%@pageimport="java.io.*"%><%Stringvote1=request.getParameter("lang");vote.n=4;vote.filePath="vote.txt";vote.cre7、ateFile();vote.readFile();if(vote1.compareTo("0")==0)vote.voteNum[0]++;if(vote1.compareTo("1")==0)vote.voteNum[1]++;if(vote1.compareTo("2")==0)vote.voteNum[2]++;if(vote1.compareTo("3")==0)vote.voteNum[3]++;vote.writeFile();%> alert("感谢你投了宝贵的一票")8、; self.location="index.jsp"; see.jsp:<%@pagecontentType="text/html;ch
3、ln("0"); fileWrite.close(); }}publicvoidwriteFile() throwsFileNotFoundException { fileWrite=newPrintWriter(newFileOutputStream(filePath)); for(inti=0;i4、ile() throwsFileNotFoundException { fileRead=newBufferedReader(newFileReader(filePath)); for(inti=0;i5、 voteNum[i]=Integer.parseInt(voteStr[i]); } try { fileRead.close(); } catch(IOExceptiond) { systemMessage=d.toString(); } }} vote.jsp:<%@pagecontentType="text/6、html;charset=gb2312"language="java"errorPage=""%><%@pageimport="java.util.*"%><%@pageimport="java.lang.*"%><%@pageimport="java.io.*"%><%Stringvote1=request.getParameter("lang");vote.n=4;vote.filePath="vote.txt";vote.cre7、ateFile();vote.readFile();if(vote1.compareTo("0")==0)vote.voteNum[0]++;if(vote1.compareTo("1")==0)vote.voteNum[1]++;if(vote1.compareTo("2")==0)vote.voteNum[2]++;if(vote1.compareTo("3")==0)vote.voteNum[3]++;vote.writeFile();%> alert("感谢你投了宝贵的一票")8、; self.location="index.jsp"; see.jsp:<%@pagecontentType="text/html;ch
4、ile() throwsFileNotFoundException { fileRead=newBufferedReader(newFileReader(filePath)); for(inti=0;i5、 voteNum[i]=Integer.parseInt(voteStr[i]); } try { fileRead.close(); } catch(IOExceptiond) { systemMessage=d.toString(); } }} vote.jsp:<%@pagecontentType="text/6、html;charset=gb2312"language="java"errorPage=""%><%@pageimport="java.util.*"%><%@pageimport="java.lang.*"%><%@pageimport="java.io.*"%><%Stringvote1=request.getParameter("lang");vote.n=4;vote.filePath="vote.txt";vote.cre7、ateFile();vote.readFile();if(vote1.compareTo("0")==0)vote.voteNum[0]++;if(vote1.compareTo("1")==0)vote.voteNum[1]++;if(vote1.compareTo("2")==0)vote.voteNum[2]++;if(vote1.compareTo("3")==0)vote.voteNum[3]++;vote.writeFile();%> alert("感谢你投了宝贵的一票")8、; self.location="index.jsp"; see.jsp:<%@pagecontentType="text/html;ch
5、 voteNum[i]=Integer.parseInt(voteStr[i]); } try { fileRead.close(); } catch(IOExceptiond) { systemMessage=d.toString(); } }} vote.jsp:<%@pagecontentType="text/
6、html;charset=gb2312"language="java"errorPage=""%><%@pageimport="java.util.*"%><%@pageimport="java.lang.*"%><%@pageimport="java.io.*"%><%Stringvote1=request.getParameter("lang");vote.n=4;vote.filePath="vote.txt";vote.cre
7、ateFile();vote.readFile();if(vote1.compareTo("0")==0)vote.voteNum[0]++;if(vote1.compareTo("1")==0)vote.voteNum[1]++;if(vote1.compareTo("2")==0)vote.voteNum[2]++;if(vote1.compareTo("3")==0)vote.voteNum[3]++;vote.writeFile();%> alert("感谢你投了宝贵的一票")
8、; self.location="index.jsp"; see.jsp:<%@pagecontentType="text/html;ch
此文档下载收益归作者所有