别人能够访问你的vote.txt 吗?
不知道vote.txt 这个文件你放到哪里了,我知道放到WEB-INF下是安全的,你可以放到那里面去。
不知道vote.txt 这个文件你放到哪里了,我知道放到WEB-INF下是安全的,你可以放到那里面去。
解决方案 »
- 求各位大侠帮忙 java导出为html文件 excel相关
- 求大侠们解惑
- 监控网站运行的定时任务
- 求CSS强制设置打印,去除多打空白页代码!
- 有关gridsphere中用ajax的问题
- 页面无法显示的问题(在线等~~~~~~)
- 大家帮助在线等!!!(在线等待)
- 关于Tomcat与IIS的一个问题
- 我以前是在applet里面写控制网页里的ocx控件的方法和属性,现在要改成jsp+javabean,javabean可以控制ocx吗?
- jsp在jbuilder中开发完后,其中webapp的web.xml和webogic.xml需要配置吗?
- 高分求解,如何在struts模式中实现显示一个目录下的所有文件,解决即给分!!!
- 有人知道这是什么编码吗?Ê÷ÐͽṹʾÀý怎样还原成汉字?
看源码
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="vote" scope="request" class="vote.vote"/>
<%
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();
%>
<script language="javascript">
alert("感谢你投了宝贵的一票");
self.location="index.jsp";
</script>
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<n;i++) fileWrite.println("0");
fileWrite.close();
}
}
public void writeFile()
throws FileNotFoundException
{
fileWrite=new PrintWriter(new FileOutputStream(filePath));
for(int i=0;i<n;i++)
{
fileWrite.println(voteNum[i]);
}
fileWrite.close();
}
public void readFile()
throws FileNotFoundException
{
fileRead=new BufferedReader(new FileReader(filePath));
for(int i=0;i<n;i++)
{
try
{voteStr[i]=fileRead.readLine();
}
catch(IOException f)
{
voteStr[i]="0";}
voteNum[i]=Integer.parseInt(voteStr[i]);
}
try
{
fileRead.close();
}
catch(IOException d)
{
systemMessage=d.toString();
}
}
}
但是,通过web如何能向vote.txt写入数据?