Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

Output A New Web Document

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

casien
Newbie


Posts: 8
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 0 (Donate)
Post: #1

Output A New Web Document


To properly display the documents it receives, the Web browsers need to know the types of documents. If the browser receives a plain text file, the file will be displayed in plain text format. If it receives an HTML file, it needs to interpret and display it in HTML format. So when the server sends a document to the client, it should tell the client what type the document is. The standard way to identify the file type is the MIME format. Here are some of the common MIME type/subtypes:

* text/plain: Plain text, which is the default type
* text/html :HTML file (UNIX)
* text/htm :HTML file (wINDOWS NT)
* image/gif: GIF image
* image/jpeg: JPEG image
* audio/x-wav: Microsoft Windows audio format
* video/mpeg: MPEG compressed video

Usually when the server sends a document back to the client, it includes the following:

* A Content-Type: indicates the MIME format.
* A blank line
* The document itself.

Let's look at an example in PERL code:

#!/usr/local/bin/perl
#-------------------------------------------
# post.pl by Zhanshou Yu
#-------------------------------------------

# Get the input for POST method
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});

#Split the name-value pairs
($name,$value)=split(/=/,$buffer);

# Substitute special character to its original character
$value=~ tr/+/ /;
$value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;

#------print the return HTML------------------

#print the MIME type
print"Content-type: text/html\n\n";

#print the HTML body
print"<html>\n";
print "<head><title>Input For POST method </title></head>\n";
print "<body><center><h1>Input for POST Method </h1>\n";
print "<h2>Here is the string you just input: $value</h2>\n";
print "</body></html>\n";

exit;

The red color code deals with sending the document back to the client. The statement:

29-09-2006 06:39 AM
Find all posts by this user Quote this message in a reply
madly
Newbie


Posts: 8
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 24 (Donate)
Post: #2

RE: Output A New Web Document


Now CGI are used on the web sites very rarely. Still many old sites continuing their CGI scripts. So CGI still plays good role on web scripting. This tutorial helps lot to know more about CGI for a beginner.

24-10-2007 05:25 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Website of the Month

Create-a-Page for Free
SOTM June 2008


Accepting Submissions
for July 2008
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 30-08-2008, 07:41 AM


Copyright © 2002-2008 MyBB Group
Powered By MyBB