You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Teutsch <b-...@northwestern.edu> on 2001/04/04 05:45:29 UTC

file reading and writing

I am trying to control some file reading and writing. I'm trying to 
transition some servlets from QuidProQuo, and the primary difficult I am 
having is figuring out how to read and write a file. I've tried to debug 
everything I can think of, mostly the permissions on all the work 
directories (localhost_8080* all set to rwx). Getting accustomed to OS 
X, I know that permissions can be a big sticking point. Although it 
could be something else completely, despite the error.

Here's the code I am trying in a simple servlet.
--
DataOutputStream fileOut;
fileOut = new DataOutputStream( new FileOutputStream("output.txt"));
fileOut.writeBytes("test");
fileOut.close();
--
A call to 
getServletContext().getAttribute("javax.servlet.context.tempdir") 
returns:
jakarta-tomcat-3.2.1/work/localhost_8080

And the servlet catches the exception:
java.io.FileNotFoundException: output.txt (Permission denied)

So, where does the servlet store things it wants to access? I'm just 
looking for something simple here, until I have the time to learn jar 
file access in general. Hopefully I'm just missing something in the 
development or config docs.

Brian Teutsch