wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to prevent to see the directory structure  in the browser? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to prevent to see the directory structure  in the browser?" Watch "How to prevent to see the directory structure  in the browser?" New topic
Author

How to prevent to see the directory structure in the browser?

Alam Vin
Greenhorn

Joined: Jul 19, 2001
Posts: 5
If I type in http://localhost:8080/examples/jsp/myjsp/
on the browser and if "myjsp" directory contains subfolders and files, it's shown on the browser. How do we prevent them not to appear on the browser? Are there any settings on web.xml file?
Does it vary for different App servers?
Thanks in advance.
Rehan Malik
Ranch Hand

Joined: Jul 09, 2001
Posts: 76
Some of the web browsers have settings which do not allow users to see the folders in a directory if there is no index file.
One quick and fast solution (if you don't have access to the web browser directly), is to throw in index.jsp (if it's JSP pages) or index.html documents into those folders (Blank pages of course) and it should take care of this.


Rehan Malik
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
Or turn off the DIR's read attribute (r) for group and others and leave execute (x).
Then you will get "FORBIDDEN" instead.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Alam Vin
Greenhorn

Joined: Jul 19, 2001
Posts: 5
I turned off the Read Attribute by right clicking on the folder and setting the attributes in the properties. But still I am able to see the directory structure. Am I missing something somewhere?
karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
if you dont get to the solution using server configuration files, then you can create an empty file named index.html (or index.htm or start.htm, depending on your server settings) and put it in the directory where you want to prevent listings. you could also write some message in this file like "your not allowed to list the content of this directory".
in apache there is a entry in httpd.conf to prevent directory listings, perhaps there is also one on apache.

karl
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to prevent to see the directory structure in the browser?
 
Similar Threads
JBoss - servlets/jsp
Localhost leads to nowhere
blank browser window
Basic Question on JSP, servlets
deployment directory