Directory Listing on Tomcat not working

Hi,

I can’t figure out how to list my directory content when there is is no index.cfm
I follow these instructions 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.

Yep. Show your servlet-mapping's from web.xml.

I throw out the commented ones.

<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 ?

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

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>

Right :

<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 :

<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

<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 …

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

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 :wink:

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.

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


<Context useHttpOnly="true">

to this:

<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