# Directory Listing on Tomcat not working

**URL:** <https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437>\
**Category:** support\
**Created:** [June 4, 2017, 5:34pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437 "2017-06-04T17:34:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![StarCmd](https://dev.lucee.org/user_avatar/dev.lucee.org/starcmd/32/642_2.png) [@StarCmd](https://dev.lucee.org/u/StarCmd)\
**Post date:** [June 4, 2017, 5:34pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/1 "2017-06-04T17:34:20Z")

</div>

Hi,

I can’t figure out how to list my directory content when there is is no index.cfm  
I follow these instructions [Apache Tomcat 8 (8.0.53) - Default Servlet Reference](https://tomcat.apache.org/tomcat-8.0-doc/default-servlet.html) “What can I change?” and set my listings parameter to true.

What i don’t understand is that I got a CFM error page. Does that mean Tomcat didn’t handle the request by itself and pass it to CFMLServlet ?

Except the listings parameter I use the standard Lucee Express installation.

Could you help ? It’s very useful to get that content during development …  
Thanks.

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [June 4, 2017, 5:52pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/2 "2017-06-04T17:52:34Z")

</div>

> [@StarCmd](#):
>
> What i don’t understand is that I got a CFM error page. Does that mean Tomcat didn’t handle the request by itself and pass it to CFMLServlet ?

Yep. Show your `servlet-mapping`’s from web.xml.

---

<div class="post-metadata">

**Author:** ![StarCmd](https://dev.lucee.org/user_avatar/dev.lucee.org/starcmd/32/642_2.png) [@StarCmd](https://dev.lucee.org/u/StarCmd)\
**Post date:** [June 4, 2017, 6:48pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/3 "2017-06-04T18:48:21Z")

</div>

I throw out the commented ones.

```auto
<servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
      <servlet-name>LuceeServlet</servlet-name>
      <url-pattern>*.lucee</url-pattern>
      <url-pattern>/index.lucee/*</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
      <servlet-name>CFMLServlet</servlet-name>
      <url-pattern>*.cfc</url-pattern>
      <url-pattern>*.cfm</url-pattern>
      <url-pattern>*.cfml</url-pattern>   
      <url-pattern>/index.cfc/*</url-pattern>
      <url-pattern>/index.cfm/*</url-pattern>
      <url-pattern>/index.cfml/*</url-pattern>
 </servlet-mapping>
  <servlet-mapping>
    <servlet-name>RESTServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>

```

if I add  
`<url-pattern>/*</url-pattern> ` then i get my listing, but any existing index are ignored … Is there a way to prioritize the mapping ?

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [June 4, 2017, 7:13pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/4 "2017-06-04T19:13:59Z")

</div>

To clarify, your `servlet-class` for default servlet is `org.apache.catalina.servlets.DefaultServlet`, right?

> [@StarCmd](#):
>
> if I add  
> \<url-pattern\>/\*\</url-pattern\> then i get my listing, but any existing index are ignored … Is there a way to prioritize the mapping ?

index file is handled by `<welcome-file-list>`, e.g.

```
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.cfm</welcome-file>
</welcome-file-list>

```

---

<div class="post-metadata">

**Author:** ![StarCmd](https://dev.lucee.org/user_avatar/dev.lucee.org/starcmd/32/642_2.png) [@StarCmd](https://dev.lucee.org/u/StarCmd)\
**Post date:** [June 4, 2017, 7:35pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/5 "2017-06-04T19:35:42Z")

</div>

> [@21Solutions](#):
>
> To clarify, your servlet-class for default servlet is org.apache.catalina.servlets.DefaultServlet, right?

Right :

```auto
<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>

```

and my welcome file are ok :

```auto
<welcome-file-list>
        <welcome-file>index.cfm</welcome-file>
        <welcome-file>index.lucee</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
</welcome-file-list>

```

with the modified default mapping

```auto
<servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
        <url-pattern>/*</url-pattern>
</servlet-mapping>

```

Any web request ending by a “/” aka “/some/path/to/folder/” show me a listing. Even if there is an index.cfm inside.  
I am trying to anderstand how Tomcat / Lucee / and so are interacting together …  
And I am a little bit confuse with the conf file that seem easy to understand but does not produce what expected …

Note that It’s ok for me, as I first wanted to access the directory listing during the development phase. I just click on the index.cfm if needed …

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [June 4, 2017, 8:30pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/6 "2017-06-04T20:30:30Z")

</div>

Well, you definitely don’t want to use `/*` for Servlet. It’s fine for Filters, but not so good for Servlets:

> <https://stackoverflow.com/questions/4140448/difference-between-and-in-servlet-mapping-url-pattern/4140659#4140659>

---

<div class="post-metadata">

**Author:** ![StarCmd](https://dev.lucee.org/user_avatar/dev.lucee.org/starcmd/32/642_2.png) [@StarCmd](https://dev.lucee.org/u/StarCmd)\
**Post date:** [June 5, 2017, 9:00am UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/7 "2017-06-05T09:00:43Z")

</div>

I was pretty sure /\* was a bad idea… I deleted it.

I tried to comment all the config elements related to Lucee and CFM.  
Now, I get the expected behavior : when there is an index.html file it is processed and I see my html page, if there is no index.html Tomcat show me the directory listing.

Does that mean there is no way to achieve this behavior with Lucee/CFM activated ?

Thanks  
This will be my last post about this topic … I surrender 😉

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [June 5, 2017, 4:36pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/8 "2017-06-05T16:36:36Z")

</div>

> [@StarCmd](#):
>
> Does that mean there is no way to achieve this behavior with Lucee/CFM activated ?

No, I have set that up like this in development a while back, but TBH it was long ago and I don’t remember the details. It was rather straightforward though, so I’m not sure why it’s giving you a hard time.

---

<div class="post-metadata">

**Author:** ![Jordan\_Michaels](https://dev.lucee.org/user_avatar/dev.lucee.org/jordan_michaels/32/577_2.png) [@Jordan\_Michaels](https://dev.lucee.org/u/Jordan_Michaels)\
**Post date:** [June 9, 2017, 10:46pm UTC](https://dev.lucee.org/t/directory-listing-on-tomcat-not-working/2437/9 "2017-06-09T22:46:20Z")

</div>

in your [lucee]/tomcat/cont/context.xml file, change this:

```auto

<Context useHttpOnly="true">

```

to this:

```auto
<Context useHttpOnly="true" resourceOnlyServlets="CFMLServlet">

```

… restart Lucee and you should get the results you’re looking for.

Documentation is here:  
[https://tomcat.apache.org/tomcat-8.5-doc/config/context.html](https://tomcat.apache.org/tomcat-8.5-doc/config/context.html)
