If you mean on the server, absolutely. Of course you have to have the proper permissions. You do it the same way you do in a java application with the java.io package. The Servlet spec mandates that the server must provide a directory to hold temporary files as well. That is stored as a File object in the context under the key javax.servlet.context.tempdir. If you mean on the client, then it gets a little tricky but there are ways to do it under the right circumstances.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Joined: Nov 13, 2003
Yeah, I meant server, but for some reason it doent work, here's my code: I'm alo wondering if the try/catches are nesacary, and where to put the myOutFile printlns. Thanks!
Joined: Jan 30, 2002
myOutFile = new PrintWriter(new FileWriter("post.txt",a)); Are you getting a compiler error? I didn't see where a was declared. No you don't need the try blocks if you don't mind any IOExceptions propagating up the chain.
You are also quite likely to get an exception or other error, because you have used a filename relative to the "current directory", a concept that doesn't make much sense in a multi-user servlet application. Try using a full path to the file you want to write.