-2

I have an JSP-application on a tomcat.

I have a application to upload files.

Now i want to delete the files. I know the relative url "aktionen/100" but I don“t know the absolute path.

On Localhost it is "C://daten/client/" for example. But i want to get them dynamically because if I host it then it is an other path.

user959456
  • 565
  • 1
  • 9
  • 13

1 Answers1

0

Relying on relative paths is a bad idea from the beginning on. Make the upload folder externally configureable by for example a VM argument or a properties file setting. E.g. when you start Tomcat, add this VM argument

-Dupload.location=/path/to/uploads

Then you can get it as follows:

File uploadFolder = new File(System.getProperty("upload.location"));
File uploadedFile = new File(uploadFolder, "aktionen/100");
// ...

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555