Voting system original code (JSP implementation)

zhaozj2021-02-16  51

This is a voting system using text files as a storage carrier:

vote.java:

// Java Documentpackage vote; import java.io *;. Import java.util *;. Public class vote extends Object {public String filePath = ""; public int n; private File voteFile; private BufferedReader fileRead; private PrintWriter fileWrite; public String systemMessage = ""; 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

}}} 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.createfile (); vote.readfile (); if (vote1.compareto (" 0 ") == 0) vote.votenum [0] ; if (vote1.com) == 0) vote.votenum [1] ; if (vote1.compareto (" 2 ") = = 0) vote.votenum [2] ; IF (vote1.com) == 0) vote.votenum [3] ; vote.writefile ();%>