File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes How to stop directory viewing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to stop directory viewing" Watch "How to stop directory viewing" New topic

How to stop directory viewing

Shaun Appleton

Joined: Oct 31, 2002
Posts: 21
I can deploy my application using Tomcat/Jboss and all works fine. But when I go to the top level directory of my web app I can see all my JSPs/Gifs etc listed as a directory listing. Does anybody know how to turn this off?
Thanks in advance
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Define a <welcome-file-list> in your web.xml file.
For instance, this one will redirect any request for the directory into a request for "index.jsp":

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12761
Look in -home-/conf/web.xml at the default servlet parameters. Set the "listings" parameter to "false" to disable directory listings in directories that don't have a "welcome" file.
I agree. Here's the link:
subject: How to stop directory viewing
Similar Threads
Reading dir
how u keep directory browsing off
what syntax to compile java clases in subdirectory
Modify all the attributes
Accessing Bean