JSP实现投票系统源码_jsp实现投票系统

2020-02-27 其他范文 下载本文

JSP实现投票系统源码由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“jsp实现投票系统”。

这是用文本文件作为存储载体的投票系统: vote.java:

package vote;import java.io.*;import java.util.*;public cla vote extends Object { public String filePath=“”;public int n;private File voteFile;private BufferedReader fileRead;private PrintWriter fileWrite;public String systemMeage=“”;private String voteStr[]=new String[10];public int voteNum[]=new int[10];public void createFile()

throws FileNotFoundException {

voteFile=new File(filePath);

if(!voteFile.exists())

{

fileWrite=new PrintWriter(new FileOutputStream(filePath));

for(int i=0;i

fileWrite.close();

} } public void writeFile()

throws FileNotFoundException

{

fileWrite=new PrintWriter(new FileOutputStream(filePath));

for(int i=0;i

{

fileWrite.println(voteNum[i]);

}

fileWrite.close();

} public void readFile()

throws FileNotFoundException

{

fileRead=new BufferedReader(new FileReader(filePath));

for(int i=0;i

{

try

{voteStr[i]=fileRead.readLine();

}

catch(IOException f)

{

voteStr[i]=“0”;}

voteNum[i]=Integer.parseInt(voteStr[i]);

}

try

{

fileRead.close();

}

catch(IOException d)

{

systemMeage=d.toString();

}

} }

vote.jsp:

<%@ page contentType=“text/html;charset=gb2312” language=“java” errorPage=“” %> <%@ page import=“java.util.*”%> <%@ page import=“java.lang.*”%> <%@ page import=“java.io.*”%> <% String vote1=request.getParameter(“lang”);vote.n=4;vote.filePath=“vote.txt”;vote.createFile();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();%>

see.jsp:

<%@ page contentType=“text/html;charset=gb2312” language=“java” errorPage=“” %> <%@ page import=“java.util.*”%> <%@ page import=“java.lang.*”%> <%@ page import=“java.io.*”%> <% String vote1=request.getParameter(“lang”);vote.n=4;vote.filePath=“vote.txt”;vote.createFile();vote.readFile();int total=0;float voteFlo[]=new float[5];for(int i=0;i 查看调查

调查结果

《JSP实现投票系统源码.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
JSP实现投票系统源码
点击下载文档
相关专题 jsp实现投票系统 源码 投票系统 jsp jsp实现投票系统 源码 投票系统 jsp
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文