Reputation: 33
I have a Java program which uses a lot of text files. The program runs perfectly fine when run as a standalone Java application. But it won't work when I call the same method from a JSP page. It says its unable to find the text files. Gives a FileNotFoundException
for each text file in the project.
Any help would be much appreciated. I am using SpringSource Tool Suite 2.8 for Mac. TC server.
This is the error:
The same for 1.txt to 99.txt:
java.io.FileNotFoundException: 100.txt (No such file or directory)
Upvotes: 1
Views: 2705
Reputation: 11080
I guess your JSP page is not running from the same location as your program did. If you are running your JSP inside Tomcat or something similar then it will be running from the server's webapps (or similar) folder. You should probably change the path specified in the JSP to fully qualify the location of the text file.
For example, don't put this:
\testfiles\hello.txt
put this
c:\bob\testfiles\hello.txt
Upvotes: 1