I use a shared Apache file library with Netbeans 6.8 + Glassfish. I am trying to change the current boot path to be in the current servlet context path, something like this: WEB-INF / upload
so I wrote:
File uploadedFile = new File("WEB-INF/upload/"+fileName);
session.setAttribute("path",uploadedFile.getAbsolutePath());
item.write(uploadedFile);
but I noticed that the library saves the downloaded files to the Glassfish folder , this is what I get when I print the absolute path of the downloaded file:
C:\Program Files\sges-v3\glassfish\domains\domain1\WEB-INF\upload\xx.rar
My question is:
- How to make the general file upload save the downloaded file along the path relative to the current servlet path, so I don’t need to specify the whole path? is it possible?