This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

create virtual directory/alias on tomcat 8.5  RSS feed

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

Posts: 20766
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • 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.
Do you want ants? Because that's how you get ants. And a tiny ads:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!