This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Restricting directory access in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Restricting directory access in Tomcat" Watch "Restricting directory access in Tomcat" New topic

Restricting directory access in Tomcat

Sathya Srinivasan
Ranch Hand

Joined: Jan 29, 2002
Posts: 379
I am developing a personal site that hosts my MP3 collection. I have a created a nice db and a couple of servlets/jsp pages that access the files and create a playlist according to some parameters from user (artist=Beatles, etc.).
Due to the copyright issues and stuff, I would like to do the following.
1. Assume that my song is in a location called
2. Assume that my jsp is in a location called
My dilemma is this.
I would like to give access in Tomcat (4.0) in such a way that when I acess the URL in (1) from URL in (2), it should be able to do so without a problem, but
When someone directly accesses URL in (1), it should be denied.
In other words, a particular directory in my site should be accessible from the links in my own site, but should be inaccessible to direct queries from other sites (external IPs).
Access from IP (my site) to 'Beatles' directory should be allowed.
Access from IP (any other site) to 'Beatles' directory should be denied.
Is there anyway to achieve this in Tomcat?? Any help would be greatly appreciated.

Cheers, Sathya Srinivasan - SCJP 1.2, SCWCD 1.2, SCMAD 1.0
Co-Author of Whizlabs SCMAD Certification Exam Simulator and SCMAD Exam Guide Book
I agree. Here's the link:
subject: Restricting directory access in Tomcat
It's not a secret anymore!