简体   繁体   中英

directory listing if no welcome page or index.html

From java EE 7 tutorial

If no welcome file is specified, GlassFish Server will use a file named index.html as the default welcome file. If there is no welcome file and no file named index.html, GlassFish Server returns a directory listing.

It's right regarding to welcome file and index.html, but it doesn't work regarding to directory listing, is this wrong info from java tutorial or I didn't understand the quoted paragraph? if the problem on the tutorial, is there any comprehensive and reliable java ee tutorial?

There is a default-web.xml file in GlassFish which configure some stuff behind the scenes. This file can be found in domains->domain->config folder.

By default, in GlassFish v3 directory listing is disabled. But one can easily enable it by modifying default-web.xml file:

<init-param>
  <param-name>debug</param-name>
  <param-value>0</param-value>
</init-param>

Or if there is no possibility to modify the default-web.xml directly, add the following to your web.xml:

<!-- Allow directory listing -->
<servlet>
  <servlet-name>default</servlet-name>
  <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
  <init-param>
    <param-name>debug</param-name>
    <param-value>0</param-value>
  </init-param>
  <init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>default</servlet-name>
  <url-pattern>/</url-pattern>
</servlet-mapping>

Hope this is helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM