write File to server with servlet

hello, I would like to write a File to the server with a servlet. I tried it with File dest = new File("test.xml"); this does not seem to work. do I have to find out the absolute path on the server? if yes, how? my servlet is running in a tomcat.

Originally posted by Lukas Benberg: hello, I would like to write a File to the server with a servlet. I tried it with File dest = new File("test.xml"); this does not seem to work. do I have to find out the absolute path on the server? if yes, how? my servlet is running in a tomcat.

thank you!

I would have written the file in the temp directory of tomcat.You can get the location of the temp directory using System.getProperty("java.io.tmpdir") .

One thing to keep in mind; getRealPath will only work if your application is being run from an exploded file system. If, on the other hand, your application is being run from a packed war archive, getRealPath will return null.