|
|
|
|
|
|
|
|
|
|
||||||
|
The
most common error that beginners do is about the output formatting. The
output should be properly formatted so that the server can understand it.
A CGI program can return almost any kind of documents. However, the client must know what kind of document you are sending so that it can present it accordingly. To tell the server
about the type of the document you are sending back, whether it be a full
document or a reference to one, CGI requires you to place a
short header on your output. This is a header composed of ASCII text, consisting
of lines sepearated by either LF and/or CR followed by a single blank line.
Content-type: text/html .............HTML
file contents.............
A reference to another document Instead of outputting the document, you can just tell the browser where to get the new one, or have the server automatically output the new one for you. Content-type:
text/html
.............HTML file contents............. Nowadays, we don't need to explicitly tell the user to go another location; instead, the browser performs the same job for us. If another file is wanted to be referenced which is obviously not protected by authentication rules and accessible, you should just output a partial (virtual) URL, such as the following: Location:
/dir1/dir2/html1.html
The server thinks that you requested: http://yourserver/dir1/dir2/html1.html |
|
|
|
|
|
|