String nameOfTextFile = "count.txt";
-->
String nameOfTextFile = "/tomcat/webapps/ROOT/";

解决方案 »

  1.   

    sorry
    String nameOfTextFile = "count.txt";
    -->
    String nameOfTextFile = "/tomcat/webapps/ROOT/count.txt";
      

  2.   

    or
    String nameOfTextFile = "count.txt";
    file = new BufferedReader(new FileReader(nameOfTextFile));
    -->
    String nameOfTextFile = "count.txt";
    file = new BufferedReader(new FileReader(request.getRealPath(nameOfTextFile)));
      

  3.   

    这样就正常了!
    <%@ page contentType="text/html;charset=gb2312" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta http-equiv="KEYWORDS" content="fsdfsdfsdf">
    <title>fdsdfsdfsdf</title>
    <link rel=stylesheet href="style.css" type="text/css">
    </head>
    <body>
    <p>&nbsp;</p>
    <%@ page import="java.io.*" %><% 
    String currentRecord = null;
    BufferedReader file; String nameOfTextFile = "count.txt";
    file = new BufferedReader(new FileReader(request.getRealPath(nameOfTextFile)));
    String readStr =null;
    int writeStr =0;   
    try
    { readStr = file.readLine(); }
    catch (IOException e)
    { System.out.println("dsdfgdfg"); }
    if (readStr == null) readStr = "dfgdsfgdsfg";
    else { writeStr = Integer.parseInt(readStr)+1;}try { 
    PrintWriter pw = new PrintWriter(new FileOutputStream(request.getRealPath(nameOfTextFile)));
    pw.println(writeStr);
    pw.close();}catch(IOException e) {
    out.println(e.getMessage());
    }
    %>
    <p align="center">dffgdsg<b><font color="red"><%=writeStr%></font></b>gfhdfghdsf</p>
    <br><br>
    <center>
    <table width="70%">
    <tr>
    <td align="center" width="20%"><a href="login.jsp">dfgdfg</a></td>
    <td align="center" width="20%"><a href="register.jsp">dfgsdg</a></td>
    <td align="center" width="20%"><a href="shade.jsp">fghfg</a></td>
    <td align="center" width="20%"><a href="appriciate.jsp">ghfghh</a></td>
    <td align="center" width="20%"><a href="forum.jsp">fgdfgh</a></td>
    </tr>
    </table>
    </center>
    <p>&nbsp;</p>
    </body>
    </html>
      

  4.   

    非常感谢 beyond_xiruo(希偌) :呵呵!给分!