This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes URGENT: Disabling directory listing in Tomcat 4.0 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 "URGENT: Disabling directory listing in Tomcat 4.0" Watch "URGENT: Disabling directory listing in Tomcat 4.0" New topic
Author

URGENT: Disabling directory listing in Tomcat 4.0

Afroz Khan
Ranch Hand

Joined: Aug 07, 2000
Posts: 105
Hi,
I have developed an application in jsp using Apache Tomcat 4.0. Application default page is a jsp page and not a index.html. but when user access the site, it displays list of files present in that folder.
In simple words, how to disable directory and files listing for the end user using Apache- Tomcat 4.0
Thanks


Afroz
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Afroz Khan:
Hi,
I have developed an application in jsp using Apache Tomcat 4.0. Application default page is a jsp page and not a index.html. but when user access the site, it displays list of files present in that folder.
In simple words, how to disable directory and files listing for the end user using Apache- Tomcat 4.0
Thanks

write an entry in web.xml for welcome page pointing to ur first JSP
Afroz Khan
Ranch Hand

Joined: Aug 07, 2000
Posts: 105
Thanks Gautam
Can u give an example for this. As to what is the tag to be used in web.xml
Thanks
Afroz
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Afroz Khan:
Thanks Gautam
Can u give an example for this. As to what is the tag to be used in web.xml
Thanks
Afroz

<welcome-file-list>

<welcome-file>/entry_page.jsp</welcome-file>
</welcome-file-list>
this path is relative to ur application context
Afroz Khan
Ranch Hand

Joined: Aug 07, 2000
Posts: 105
Hi gautam,
i guess i put the question in a different way. i mean we have a access folder. my application is http://127.0.0.1/gdc/Login.jsp
and when the user enters the url till like http://127.0.0.1/gdc it displays the liting of the files and folders.
Thanks
Afroz
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Afroz Khan:
Hi gautam,
i guess i put the question in a different way. i mean we have a access folder. my application is http://127.0.0.1/gdc/Login.jsp
and when the user enters the url till like http://127.0.0.1/gdc it displays the liting of the files and folders.
Thanks
Afroz

just put ur login.jsp in gdc folder.
write followinf entry in web.xml
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
then type URL http://127.0.0.1/gdc
and see what happened.
I've had tested this thing already on tomcat.
and if after that it doesn't work then u just contact me on gautam_shah_29@yahoo.com . i am online there . i will show u on my static machiene.
Afroz Khan
Ranch Hand

Joined: Aug 07, 2000
Posts: 105
Thanks Gautam
I got my problem solved and its working fine now. Thanks again
Afroz
sony gam
Greenhorn

Joined: Jun 20, 2001
Posts: 28
Hi,
If suppose i have several folders in my web app, then how can i acheive this.
Because obviously there can be only one welcome file for a web aplication.
Thank you,
Sony gam
sampy jagan
Ranch Hand

Joined: Sep 17, 2002
Posts: 34
In Web.xml, set the listing attribute to false to disable the directory browsing.
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
Hope this helps...
Regards
jagan
sampy jagan
Ranch Hand

Joined: Sep 17, 2002
Posts: 34
Sorry, Ignore my prev reply.
For Tomcat change the listings attribute of the StaticInterceptor to false in Server.xml
Ex:
<StaticInterceptor listings="false" />
Regards
jagan
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
Hi Sony
For every context(Folder) in tomcat there is web.xml file in WEB-INF folder,so for every contecxt u need to make change in that file
hope this helps
..Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URGENT: Disabling directory listing in Tomcat 4.0
 
Similar Threads
Tomcat Configuration -Help pls
restrict directory access using apache
getAttribute in a jsp
Directory Listing
servlet program always show same result after modifing