File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Location for uploaded files in Tomcat

 
Tony Walters
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic