Well - the exception says quite clearly what happens: "No such file or directory".
I guess you placed a BuildingInfo.txt somewhere, but not where it is expected.
Since you did not tell us - let me guess: You placed it in the webapps home directory.
But the
JSP seems to search somewhere else. Hmm how can we find out where the JSP is looking for it?
Just let's simply turn it the other way round and let the JSP write some code. Then we will see which directory is used.
So add a few lines in front of your existing code:
<%try {
FileWriter writer = new FileWriter("BuildingInfo.txt");
writer.write("here it is");
writer.close();
}
catch(Exception e){
out.print("Exception :"+e.toString());
}%>
You can add this in front of your existing code and you will see a "working good" in your browser window.
Why is this? Because the file has been written to the place where the JSP expects it. So your other code now can find it (of course not the one you wanted to read, but the one containing the "here it is" which has been created before).
Now you can use the find command of your OS to locate it.
Let's assume you use Windows you will find it in C:\
This is not very surprising, because you did not name any directory so the VM uses the root directory of your OS.
You need to give the full path if you want to read/write from a particular place in the filesystem.
sl
Hartmut