• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

create virtual directory/alias on tomcat 8.5

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


I want http://localhost:8080/temp_mp3/ to point to c:\temp_mp3
e.g. :  http://localhost:8080/temp_mp3/02_Queen_Radio%20Ga%20Ga_14855533586894.mp3 should point to c:\temp_mp3\02_Queen_Radio Ga Ga_14855533586894.mp3

I use Tomcat 8.5 and windows 10


Kr
Martin
 
Bartender
Posts: 20982
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Martin!

First, I have to issue the customary warning that a WEB server is not a file server. So when you use a url like http://localhost:8080/temp_mp3/02_Queen_Radio%20Ga%20Ga_14855533586894.mp3, you're not getting something that the client can do a "file open/read/close" operation on, instead the webapp's WAR resources are queried to find something mapped to the WAR path "/temp_mp3/02_Queen_Radio%20Ga%20Ga_14855533586894.mp3", which the webapp server will copy to the HTTP response output for the client to send to a local app or save (depending on the client configuration).

In the course of normal events, then, attempting to retrieve a file from a directory outside of the WAR wouldn't be possible. What you'd have to do is create a servlet mapped to the WAR resource path '/temp_mp3' and code that servlet to look in directory c:\temp_mp3\ for the requested mp3., which it would then open and copy to the HttpResponse stream.

Tomcat does have a limited ability to simplify that, although it requires relaxing the normal security configuration. In such a case, you'd have to unzip (explode) the WAR to a directory (actually this is default for Tomcat), then create a soft-link from the WAR's /temp_mp3 resource path to C:\temp_mp3. PLUS you have to change the normal security constraints in the TOMCAT_HOME/conf/server.xml file to allow Tomcat to follow softlinks. That would allow the particular resource organization that you say you want.
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!