0

I'm trying to upload a number of website directories to a server with spring, and generate links so i can view them later on. I realized i can't put web directories right into the standard resources folder because that's inside the web archive, and if i try to use an external resources folder it just gets shuffled into the web archive when the app is built. My other possible approach would be to make a separate downloads servlet, but that seems like it wouldn't work because if it only downloads the index.html file from the site, it wouldn't also show the other files that the site depends on, which is not what i want.

I understand that relying on system paths is not very portable but probably this program will only run on at most 3 or 4 linux computers so I could just set up the file path on them manually if i can't just do it from within the java program itself.

legs
  • 33
  • 6
  • Are you deploying a Spring Boot app or a Spring app? You could try this solution: https://stackoverflow.com/questions/2404528/map-external-directory-to-web-xml – Compass Jun 25 '18 at 19:30
  • I'm pretty sure that what i'm doing is a Spring App, though i'm not entirely sure what the difference is. I can't tell if the linked thing is what I'm looking for but I'll see if it works for me somehow. – legs Jun 25 '18 at 19:45
  • A Spring Boot application typically brings along its own Tomcat server if it is a web service for deployment simplicity. A Spring application would usually be deployed onto an active Tomcat. If you have an active Tomcat you can deploy a web.xml to do what you want. For a Spring Boot you have to configure it through Java entirely, is the gist of it. – Compass Jun 25 '18 at 20:01
  • it's definitely a spring app, but I'm having trouble seeing how to add the new context into the web.xml file. If i insert it into tomcat's server.xml file like was done in the previous thing, would that wipe out the previous root directory? i still want to be able to access the original folder directly. – legs Jun 25 '18 at 20:20
  • You might have better mileage with a directory listing like this. https://stackoverflow.com/questions/7068046/how-can-i-list-all-the-files-in-folder-on-tomcat You can do this in parallel with your spring app's web.xml to expose sub-directories – Compass Jun 25 '18 at 21:01

0 Answers0