File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes get to files on another partition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "get to files on another partition" Watch "get to files on another partition" New topic
Author

get to files on another partition

m pasha
Greenhorn

Joined: Mar 15, 2011
Posts: 2
Helo,

i have a problem i don't know how to solve.

I have tomcat installed for example on C:/SERVER/Tomcat

I have some files like .txt and .mp3 on D:/data/

now the page works fine... i can acces it ower http://localhost:80

but how can i access to the files on D:/data ower HTTP protocol??

like http://localhost:80/D/data

???
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16011
    
  19

Welcome to the JavaRanch, D Pasha!

HTTP is not a file server protocol. So you can't access files through it.

What you can do is setup a webapp that returns the contents of a file in response to a URL request. That is default behavior for resources inside a WAR (except for WEB-INF and its children). For any other location, however, you have to provide your own file-transfer logic. This can be done with a fairly simple servlet that parses the URL to build a filename path, opens the file and copies its contents to the HttpServletResponse data stream.


Customer surveys are for companies who didn't pay proper attention to begin with.
m pasha
Greenhorn

Joined: Mar 15, 2011
Posts: 2
SOLVED!

i had to put COntextPath to do HOST part in the server.xml file of Tomcat Config folder



i can get to the files like .mp3 now like

http://localhost/files/test.mp3

thanks anyway Tim

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get to files on another partition