Re: cgi not found

Christopher Schultz <[email protected]> Fri, 10 Apr 2026 09:26:28 -0400
Newsgroups gmane.comp.jakarta.tomcat.user
Message-ID <[email protected]>
Holger,

On 4/10/26 8:39 AM, Holger Klawitter wrote:
> I have made a strange observation with the cgi servlet (enabled in
> local web.xml) using tomcat 9.0.117 (also *.111):
> 
> when I use a subdirectory as a url pattern, everything works fine,
> but when I use a file suffix pattern, the scripts are not being found and
> I am getting 404.
> 
>      <servlet>
>          <servlet-name>cgi</servlet-name>
>          <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
>          <load-on-startup>5</load-on-startup>
>          <init-param>
>            <param-name>executable</param-name>
>            <param-value>/usr/bin/python3</param-value>
>          </init-param>
>      </servlet>
> 
>      <servlet-mapping>
>        <servlet-name>cgi</servlet-name>
>        <url-pattern>/bin/*</url-pattern><!-- works -->
>        <url-pattern>*.py</url-pattern><!-- does not work -->
>      </servlet-mapping>
> 
> * Priviledged is enabled
> * no cgiPathPrefix is set.
> * I tried with and without the executable init-param
> * python is there and the script exists in ./simple.py and bin/simple.py
> 
> What's wrong here?
> 
> I can provide a minimal war file if needed.

The CGIServlet requires a path-mapping and won't work with an extension 
mapping. It's non-trivial to make an extension mapping work, and 
typically in a web application all CGIs are rooted in the same place, 
anyway.

So you'll need to use a path-mapping.

-chris