• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Location for uploaded files in Tomcat

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm uploading some files to Tomcat via a webapp. I was surprised to find the default location was to store uploaded files in the bin directory. Is there a uploaded file location specified for all J2EE-compliant JPS/Servlet containers, and how do I get it?

Advice gratefully received.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are saving files in a way that depends on the "current" directory, there is no way of telling where they will end up. You must use code that controls the complete file path.
Bill
 
Tony Walters
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I do that, the system won't be portable to another app server, or another computer. At the very least this system will at some point be on a production server, rather than a dev one.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. you can make the path to the file storage directory a configurable parameter in web.xml with init-param tags. Convenient for user configuration.
2. you can make the path an environment variable
3. you can make the path relative to the web app installation - see ServleContext.getRealPath()
4. etc. plenty of other possibilities.....
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic