File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Accessing wav files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Accessing wav files" Watch "Accessing wav files" New topic

Accessing wav files

Michael Reynolds

Joined: Dec 26, 2005
Posts: 12
I am rather new to Tomcat and only a little more experienced in the ways of JAVA. My windows application needs to access WAV files via HTTP. I would like to access files in say... "C:/prompts" on my server "//" for example. How do I make this path visible via HTTP? Is there a configuration file with which I can point to my virtual directory so that the URL becomes something like: ""?
K. Tsang

Joined: Sep 13, 2007
Posts: 2247

This looks like more of Tomcat configuration issue. Moving

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41188
You would use the docBase attribute of the Context element to point to an arbitrary directory outside of the Tomcat installation:

Ping & DNS - my free Android networking tools app
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964

The simplest way would be to merely include copies of the wav files as part of your WAR and not attempt to kludge around things.

Relocating the entire WAR (as Ulf suggested) probably wouldn't do what you wanted, since the ENTIRE war has to be relocated, but depending on how things are set up, it might be a possibility.

Windows added a file aliasing feature similar to Unix/Linux softlinks a few years back, and this can be used to make the WAV directory appear to be part of the WAR, although you may have to change some settings in server.xml, since softlinks are somewhat of a security issue and thus disabled by default.

And then there's the old standby: write a servlet that copies the WAV from its actual external home out to the HttpResponse output stream (which is what the default servlet does for in-WAR files anyway).

Customer surveys are for companies who didn't pay proper attention to begin with.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41188
Tim Holloway wrote:Relocating the entire WAR (as Ulf suggested) probably wouldn't do what you wanted, since the ENTIRE war has to be relocated

Actually, what I meant -but didn't say explicitly- was to create a second web app that would do nothing but serve files from this directory. I agree that moving the entire web app would likely not be a practical approach.
I agree. Here's the link:
subject: Accessing wav files
Similar Threads
how to read content of a site?
Question about java.lang.SecurityException
Tomcat Setup
Edit audio meta tag
internal or external request.