File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URGENT: Disabling directory listing in Tomcat 4.0

 
Afroz Khan
Ranch Hand
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
gautam shah
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 105
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gautam
I got my problem solved and its working fine now. Thanks again
Afroz
 
sony gam
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 642
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic