This week's book giveaway is in the XML and Related Technologies forum.
We're giving away four copies of Java XML & JSON and have Jeff Friesen on-line!
See this thread for details.
Win a copy of Java XML & JSON this week in the XML and Related Technologies 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

create virtual directory/alias on tomcat 8.5  RSS feed

 
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: 20307
110
Android Eclipse IDE 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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!