Default Document for Directory with RequestDispatcher

Discussion in 'Java' started by fritz-bayer@web.de, Aug 17, 2005.

  1. Guest

    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
     
    , Aug 17, 2005
    #1
    1. Advertising

  2. wrote:
    >
    > 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
     
    Babu Kalakrishnan, Aug 17, 2005
    #2
    1. Advertising

  3. writes:

    > 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.
     
    Tor Iver Wilhelmsen, Aug 18, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Vincent Craven

    Multiple includes with RequestDispatcher

    Paul Vincent Craven, Aug 29, 2003, in forum: Java
    Replies:
    0
    Views:
    663
    Paul Vincent Craven
    Aug 29, 2003
  2. Will Handley
    Replies:
    1
    Views:
    598
    Nigel Wade
    Dec 10, 2003
  3. Ryan Stewart

    RequestDispatcher.include() behavior

    Ryan Stewart, May 20, 2004, in forum: Java
    Replies:
    0
    Views:
    506
    Ryan Stewart
    May 20, 2004
  4. DiscoStu
    Replies:
    1
    Views:
    526
    Erwin Moller
    Jul 20, 2004
  5. John English
    Replies:
    6
    Views:
    3,951
    Andrea Desole
    Jul 19, 2005
Loading...

Share This Page