Default Document for Directory with RequestDispatcher

F

fritz-bayer

Hello,

I'm using the RequestDispatcher to forward to urls. When the url ends
as an directory path, such as "/help/programming/" or "/help/java" then
my servlet engine (tomcat 5.5) displays the contents of the directory.

What I would like to achieve is that tomcat looks for a default
document to return, when a directory is access instead of returning
it's contents. Does anybody know how to do this?

Fritz
 
B

Babu Kalakrishnan

I'm using the RequestDispatcher to forward to urls. When the url ends
as an directory path, such as "/help/programming/" or "/help/java" then
my servlet engine (tomcat 5.5) displays the contents of the directory.

What I would like to achieve is that tomcat looks for a default
document to return, when a directory is access instead of returning
it's contents. Does anybody know how to do this?

Depends on which servlet the request would map to :

If the url prefix maps to any servlet context that is defined, the
web.xml deployment descriptor of the servlet is consulted for a
<welcome-file-list> element.

If not, the "default" servlet's web.xml file is used (which is
conf/web.xml in the tomcat installation directory).

You can also set the value of the init-param called "listings" to false
to avoid displaying a directory listing in case no file specified in the
welcome-file-list is found in the directory. (Never verified it for user
specified contexts - but it does work for the default servlet - i.e when
the request doesn't map to any servlet context found)

BK
 
T

Tor Iver Wilhelmsen

What I would like to achieve is that tomcat looks for a default
document to return, when a directory is access instead of returning
it's contents. Does anybody know how to do this?

Look for the description of the <welcome-file-list> element of
web.xml.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top