In my vps, I want to upload a file to the Logos directory. The directory structure is as follows on my vps -
/home/webadmin/domain.com/html/Logos
When a file is downloaded through my jsp page, this file is renamed, and then I want to put it in the Logos directory .... but I can not find the path in the servlet code.
Servlet code snippet -
String upload_directory="/Logos/";
File savedFile = new File(upload_directory,BusinessName+"_Logo."+fileExtension);
I tried a lot of options, but still fail. What is the correct way to indicate the path?
Edited
The problem with using getServletContext () is that it returns the path to the directory where Tomcat and my webapp ..., while I want to get to the directory where my html and image files are located, in the vps root directory. How to indicate this path?
String server_path = getServletContext().getRealPath("/");
String upload_directory = "Logos/";
String complete_path = server_path + upload_directory;
File savedFile = new File(complete_path,"NewLogo.jpg");
source
share