0

I'm having some issues writing a relative path.

I have a servlet trying to save an image under the web directory.

This is the servlet location: onlineShop/src/main/java/control/servlets/itemManagement

And this is the directory where I want to save the image: onlineShop/web/UploadedPhotos

What is the relative path to indicate (to the servlet) the directory in which to save the image?

ChiefTwoPencils
  • 13,548
  • 8
  • 49
  • 75
user3808750
  • 13
  • 2
  • 9
  • check this answer http://stackoverflow.com/questions/204784/how-to-construct-a-relative-path-in-java-from-two-absolute-paths-or-urls – Steve YonG Feb 04 '16 at 02:30
  • Hhhm.. It's a good approach, but I was looking for a real relative path, don't know if it's possible. @SteveYonG – user3808750 Feb 04 '16 at 02:36

1 Answers1

1

try this one

getClass().getResource("").getPath() + "fileName";
Steve YonG
  • 80
  • 7