Re: Reading a text file from a JSP page - i keep getting a java.io.FileNotFoundException
Posted By:
Vladislav_Kamensky
Posted On:
Monday, August 12, 2002 04:05 AM
Point is that
FileReader file = new FileReader("test.txt");
Is not referred to the same directory where jsp file is.
I think you should use the following method:
ServletContext#getRealPath(java.lang.String path)
Returns a String containing the real path for a given virtual path. For example, the path "/index.html" returns the absolute file path on the server's filesystem.
Result of this method you should use as parameter for FileReader.