This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to stop directory viewing" Watch "How to stop directory viewing" New topic
Author

How to stop directory viewing

Shaun Appleton
Greenhorn

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
Shaun
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":
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


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

Joined: Mar 22, 2000
Posts: 12759
    
    5
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.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
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