This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Storing Files Outside of Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Storing Files Outside of Tomcat" Watch "Storing Files Outside of Tomcat" New topic

Storing Files Outside of Tomcat

Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
I would like to be able to store files that will be linked off a web page outside of the web application itself. This would allow me to redeploy without having to backup all the files first. How do I do that?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Since servlet containers are not allowed to directly serve resources stored outside the application directory structure you will have to be indirect. Make your link point to a servlet that can use the file system to read and send the files.

Note that you will have to pay attention to setting the headers for content type and length.


Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86

Do you have an example or a link to an example of the servlet approach that you recommend? Thanks.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63874

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Storing Files Outside of Tomcat
It's not a secret anymore!