jsp实现投票系统源码

jsp实现投票系统源码

ID:34723966

大小:65.18 KB

页数:5页

时间:2019-03-10

jsp实现投票系统源码_第1页
jsp实现投票系统源码_第2页
jsp实现投票系统源码_第3页
jsp实现投票系统源码_第4页
jsp实现投票系统源码_第5页
资源描述:

《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;i

3、ln("0");       fileWrite.close();       }}publicvoidwriteFile()    throwsFileNotFoundException    {    fileWrite=newPrintWriter(newFileOutputStream(filePath));    for(inti=0;i

4、ile()       throwsFileNotFoundException         {         fileRead=newBufferedReader(newFileReader(filePath));         for(inti=0;i

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

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。