tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cox, Charlie" <c...@cincom.com>
Subject RE: Help! CGI unreliable under Tomcat
Date Wed, 23 Apr 2003 12:49:52 GMT
This is good to know. however I have one suggestion. see below.

> -----Original Message-----
> From: Marc Chamberlin [mailto:marcc@easystreet.com]
> Sent: Wednesday, April 23, 2003 3:38 AM
> To: Tomcat Users List
> Subject: Re: Help! CGI unreliable under Tomcat
> 
> 
> 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 CGIServlet.java file and I have attached it to this
> email.
> 
> 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 CGIServlet.java 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".
> 
> Solution:
> 
> 1) to eliminate issue (3) above, CGIServlet.java was modified 
> so that when it builds a command to execute, it does not change the
> cgi commands from
> <command> <arg1> <arg2> ... <argn>
> to
> 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
> contents.
> % htmlcat <mimetype> <filepath>
> This is done so that:
>         a) *.html files are presented as HTML mime type
>     and
>         b) *.jpg files are presented as  
> application/image-jpeg mime type
> 

instead of this htmlcat, you could look at how the DefaultServlet determines
the content type for the given request and use that to set the content type
in your CGIServlet. This would allow you to use the content types defined in
conf/web.xml which would be consistant with your other tomcat applications.

Charlie


> This is done by providing
>         a)  new conditional code in CGIServlet.java -- see 
> attached for details.
>         b) the following short bash script made available in 
> tomcat's execution path:
>            htmlcat:
>       #! /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
>       echo
>       cat $2
> 
> Hope this helps you, other CGI developers and Tomcat users.   
>  Marc.....
> 
> 
> 
> ----- Original Message -----
> From: "Graham Freeman" <g-freeman@adfa.edu.au>
> To: <tomcat-user@jakarta.apache.org>
> 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.
> > java.io.IOException: Broken pipe
> >     at java.io.FileOutputStream.writeBytes(Native Method)
> >     at java.io.FileOutputStream.write(FileOutputStream.java:257)
> >     at
> > 
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:69)
> >     at 
> java.io.BufferedOutputStream.flush(BufferedOutputStream.java:127)
> >     at 
> java.io.BufferedOutputStream.flush(BufferedOutputStream.java:128)
> >     at
> > 
> org.apache.catalina.servlets.CGIServlet$CGIRunner.run(CGIServl
> et.java:1683)
> >     at 
> org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:635)
> >     at 
> org.apache.catalina.servlets.CGIServlet.doPost(CGIServlet.java:597)
> > ...
> >
> > 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 g-freeman@adfa.edu.au
> > School of Computer Science Phone +61-2-6268 8186
> > Australian Defence Force Academy Fax +61-2-6268 8581
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message