Skip to main content

Problem:

Using the DISPLAY verb in a CGI program gives an Interrnal Server Error 500 when deployed using the Apache web server, however the same DISPLAY works fine with other web servers such as Solo.

Resolution:

The problem is with the way that Apache works rather than Server Express.  The following can be found on the Apache website:

http://httpd.apache.org/docs/2.2/howto/cgi.html#writing

----------->

There are two main differences between "regular'' programming, and CGI programming.

First, all output from your CGI program must be preceded by a MIME-type header. This is HTTP header that tells the client what sort of content it is receiving. Most of the time, this will look like:

Content-type: text/html

Secondly, your output needs to be in HTML, or some other format that a browser will be able to display. Most of the time, this will be HTML, but occasionally you might write a CGI program that outputs a gif image, or other non-HTML content.

Apart from those two things, writing a CGI program will look a lot like any other program that you might write.

<-----------

So, just doing a DISPLAY "anything" won't have the MIME type & so isn't in a browser compatible format.  Therfore Apache throws the error 500.

There are two programatic work-arounds to this problem:

1.  Use EXEC HTML DISPLAY "something" END-EXEC as this will send a HTML header.

2.  Use DISPLAY ws-myform at the beginning of the program where ws-myform is declared as:

     01  ws-myform is external-form identified by "headerl.html".

and header.html containes <html>.  The other DISPLAY's in the program can remain unchanged.

Old KB# 2286