tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc Chamberlin" <>
Subject Re: Help! CGI unreliable under Tomcat
Date Wed, 23 Apr 2003 07:38:05 GMT
Graham -

I recently posted a request to this group requesting help installing Bugzilla on a Linux box
using Tomcat as the server. I got one
reply which essentially said this was not a good idea, but that was an inappropriate answer
for our situation. Anywise, like you, we
faced a lot of CGI/Tomcat issues because Bugzilla is based on a lot of Perl CGI scripts. So
we have forged ahead and now got it
working and I will describe what we found and did below. Some of this may apply to you, and
some of this might be of interest to the
Tomcat developers. In addition to what I describe below, we had to change the
file and I have attached it to this

Bugzilla and Tomcat's CGI-bin servlet don't get along with each other without mods.

The issues that we ran into:

1) bugzilla depends on apache's ability to have different behaviors for the files in the same
directory based on file extension.
Especially, it depends on some files having content to be provided according to mime type,
and other files to be executed to create
HTML at standard out.

2) tomcat's cgibin behavior provided by does not provide for different behaviors
as in (1) above.

3) tomcat's cgibin seems to have used perl as a replacement for the natural behaviors of exec()
in unix.  My suspicion is that  this
was done to make cgibin easier for people using perl under Windows.  The problem is that when
Perl is invoked by Perl, it cannot add
certain behaviors -- specifically, cannot add "Templates" with a "-T" option.  Thus the bugzilla
scripts that depend on "-T" must be
invoked directly, not by a parent perl "shell".


1) to eliminate issue (3) above, was modified so that when it builds a command
to execute, it does not change the
cgi commands from
<command> <arg1> <arg2> ... <argn>
perl <command> <arg1> <arg2> ... <argn>

2) to provide for JPG files and HTML files to be presented directly for their content, the
command prefixing capability that used to
be used to use perl as a shell is used to invoke a new action that simply puts an HTML/mime
header at the front and cat the file
% htmlcat <mimetype> <filepath>
This is done so that:
        a) *.html files are presented as HTML mime type
        b) *.jpg files are presented as  application/image-jpeg mime type

This is done by providing
        a)  new conditional code in -- see attached for details.
        b) the following short bash script made available in tomcat's execution path:
      #! /bin/bash

      #date >> /var/log/tomcat4/mine
      #echo PWD: $PWD >> /var/log/tomcat4/mine
      #echo $0: $* >> /var/log/tomcat4/mine

      echo HTTP/1.1
      echo Content-Type: $1
      cat $2

Hope this helps you, other CGI developers and Tomcat users.    Marc.....

----- Original Message -----
From: "Graham Freeman" <>
To: <>
Sent: Tuesday, April 22, 2003 5:18 PM
Subject: Help! CGI unreliable under Tomcat

> (This message was sent last week, without reply.)
> I have successfully installed Tomcat 4.1.24 on port 80 on a Linux box,
> with it processing JSP and servlets without error.  I have set up a
> simple CGI demonstration and enabled CGI in a container.  I am observing
> unpredictable behaviour.  Sometimes (30% of the time) the CGI program
> generates a successful response.  On all other occasions, the web page
> generated is
> HTTP Status 500
> Exception report
> The server encountered an internal error () that prevented it from
> fulfilling this request.
> Broken pipe
>     at Method)
>     at
>     at
>     at
>     at
>     at
> org.apache.catalina.servlets.CGIServlet$
>     at org.apache.catalina.servlets.CGIServlet.doGet(
>     at org.apache.catalina.servlets.CGIServlet.doPost(
> ...
> I understand that messages like this reported in a log file indicate
> that connection to the client was lost.  This does not seem to be the
> case here; the client also receives this "broken pipe" message.
> Has anyone else observed this problem and found a way around it?
> The only connector I am using is the tomcat4.CoyoteConnector.
> The CGI servlet is org.apache.catalina.servlets.CGIServlet.
> The CGI program is a 4-line shell script.
>    #!/bin/sh
>    echo Content-type: text/html
>    echo
>    echo CGI is working fine
> --
> ------------------------------------------------------------------------
> Dr Graham Freeman
> School of Computer Science Phone +61-2-6268 8186
> Australian Defence Force Academy Fax +61-2-6268 8581
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message