File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes ROOT directory behavior Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "ROOT directory behavior" Watch "ROOT directory behavior" New topic

ROOT directory behavior

Jerome Chauveau

Joined: Nov 14, 2005
Posts: 5
Hi all.

I create a directory test in webapps/ROOT.
When I go to url http://localhost:8080/test, a listing of the content of this directory is displayed.

Is there a way to have the same thing for directories not located in ROOT dir (for instance, D:/mydirs)?

Thanks in advance,

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Directory listing capability can be controlled on an application basis by an entry in web.xml - find the <servlet> entry for the default servlet and use the listings parameter.

in the default web.xml is what I suggest for security purposes.
Jerome Chauveau

Joined: Nov 14, 2005
Posts: 5
Thank you for your answer, Bill.

I stil can get the listing to appear.
What I did :
1 - Created directory t on c:/.
2 - Added
<Context path="/t" docBase="c:/t" crossContext="false" debug="1" reloadable="true" >
into server.xml (after </host)
3 - Created WEB-INF direcroty in c:/t.
4 - Created a web.xml file into this directory with the init-param you gave me.

When i type : http://localhost:8080/t, it says : Resource /t was not found.

I think my context definition is not good or misplaced, I've tried several things but cannot get it to work.

Thanks in advance for your help.

[ November 14, 2005: Message edited by: Jerome Chauveau ]
Jerome Chauveau

Joined: Nov 14, 2005
Posts: 5
Hi all

I found the solution : the <context> must be between the <host></host>.

And it works fine, thanks again Bill.

I agree. Here's the link:
subject: ROOT directory behavior
It's not a secret anymore!