Database Reference
In-Depth Information
Content-Type: text/html; charset=UTF-8
<html>
<head>
<meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" />
</head>
For static HTML pages, the web server produces header information automatically.
When you write a web script, you may need to provide the header information yourself.
Some APIs (such as PHP) send a content-type header automatically, but enable you to
override the default type. For example, if your script sends a JPEG image to the client
instead of an HTML page, the script should change the content type from text/html
to image/jpeg .
Writing web scripts also differs from writing command-line scripts, for both input and
output. On the input side, the information given to a web script is provided by the web
server rather than by input entered at the command line. This means your scripts do
not obtain data using input statements. Instead, the web server puts information into
the execution environment of the script, which then extracts that information from its
environment and acts on it.
On the output side, command-line scripts typically produce plain-text output. Web
scripts can do that, too, or instead produce HTML, images, audio, and so forth. Such
output produced in a web environment usually must be highly structured to ensure that
it can be understood by the receiving client program.
Any programming language enables output generation using print statements. Some
languages also offer special assistance for producing web pages, typically by means of
special modules:
• For Perl scripts, a popular module is CGI.pm. It provides features for generating
HTML markup, form processing, and more.
• In Ruby, the cgi module provides capabilities similar to CGI.pm.
• PHP scripts are written as a mix of HTML and embedded PHP code. That is, you
write HTML literally into the script, and then drop into “program mode” whenever
you need to generate output by executing code. PHP replaces the code by its output
in the resulting page that is sent to the client.
• Python has cgi and urllib modules that help perform web programming tasks.
• Java scripts written according to the JSP specification can use scripting directives
and code embedded within web pages. This is similar to how PHP works.
Search WWH ::




Custom Search