Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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: 12913
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: 62312

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Storing Files Outside of Tomcat