1.4 Server-Side Technologies


In this section we are going to give a clue on selected server-side technologies with quick examples on each
one, and then we will introduce Servelt and JSP as a part of server-side technologies but in separated sections.
Common Gateway Interface (CGI)
The Common Gateway Interface (CGI) is a simple interface for running external programs, software or
gateways under an information server in a platform-independent manner. Currently, the supported
information servers are HTTP servers. The interface has been in use by the World-Wide Web since 1993.
This specification defines the interface known as `CGI/1.1' (Robinson and Coar 2004).
CGI is different from a plain HTML document. HTML is static whileCGI is dynamic. Also CGI executes in real
-time to output information to end-user. Of course there are new technologies that can do what have been
done by CGI; for this reason, over time, CGI has become generalized to refer to any program that runs on a
Web server and interacts with a browser. However, CGI in many ways is more versatile (Robinson and Coar
2004).
How CGI Scripts Work. The process by which CGI scripts are executed is as the following:
The web browser sends a HTTP request for a CGI script to the server.
The server receives the request, finds the CGI script and passes some parameters and environment
information to it and executes the program.

1.4 Server-Side Technologies


Once the CGI program starts to run, it sends its output back to the server.
The web server takes the CGI program output, adds its own headers and sends the whole thing back to the browser.
Figure 1.6: How CGI Works
"Hello World" Example.
The following CGI script was created using Perl:

1.4 Server-Side Technologies


The above example can be implemented using other technologies as well, but many of these other means
developed after CGI. Then, CGI has become a standard, and many programmers prefer simply to "tweak"
their old CGI scripts for new purposes, instead of starting from scratch with the newer languages.
Also, CGI is more versatile in many ways. A traditional CGI application using Perl, for instance, can be run
on a large number of platforms with a wide variety of Web servers (Robinson and Coar 2004).
CGI has its disadvantages though. Many of the newer languages developed in response to CGI being slow,
so they are significantly faster. Also, there are significant security issues with CGI.
Since a file that uses CGI is executable, it is equivalent to letting anyone in the world run a program on your
machine. Obviously, this is not the safest thing to do.
For this reason, many Web hosts do not allow users to run CGI scripts. In this case, though, you can have
your CGI applications hosted for you remotely (Robinson and Coar 2004).
Related is the fact that programs that use CGI scripts need to reside in a special directory, so that the server
knows to execute the program rather than simply display it to the browser.
This directory, commonly /cgi-bin, is under the direct control of the Webmaster. This prohibits the average
user from creating and running programs that use CGI (W3 Security FAQ n.d.).

1.4 Server-Side Technologies


PHP: Hypertext Preprocessor
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose
scripting language that is especially suited for web development and can be embedded into HTML (php
n.d.).
Instead of lots of commands to output HTML (as seen in C or Perl), PHP pages contain HTML with
embedded code that does "something" (in this case, output "Hi, I'm a PHP script!"). The PHP code is
enclosed in special start and end processing instructions <?php and?> that allow you to jump into and out of
"PHP mode."

1.4 Server-Side Technologies


What distinguishes PHP from something like client-side JavaScript is that the code is executed on the
server, generating HTML which is then sent to the client. The client would receive the results of running that
script, but would not know what the underlying code was. You can even configure your web server to
process all your HTML files with PHP, and then there's really no way that users can tell what you have up
your sleeve.
PHP can be deployed on most Web servers and also as a standalone shell on almost every operating
system and platform, free of charge. PHP was a competitor to Microsoft's Active Server Pages (ASP) server-
side script engine and similar languages, but gradually received better acceptance and is now installed on
more than 20 million Web sites and 1 million Web servers (php usage n.d.).
Active Server Pages (ASP)
Microsoft® Active Server Pages (ASP) is a server-side scripting technology that can be used to create
dynamic and interactive Web applications.
An ASP page is an HTML page that contains server-side scripts that are processed by the Web server
before being sent to the user's browser. You can combine ASP with Extensible Markup Language (XML),
Component Object Model (COM), and Hypertext Markup Language (HTML) to create powerful interactive
Web sites (MSDN n.d.).

1.4 Server-Side Technologies


Server-side scripts run when a browser requests an .asp file from the Web server. ASP is called by the Web
server, which processes the requested file from top to bottom and executes any script commands. It then
formats a standard Web page and sends it to the browser (MSDN n.d.).
It is possible to extend your ASP scripts using COM components and XML. COM extends your scripting
capabilities by providing a compact, reusable, and secure means of gaining access to information. You can
call components from any script or programming language that supports Automation. XML is a meta-markup
language that provides a format to describe structured data by using a set of tags (MSDN n.d.).
This next example incorporates a FOR loop in the ASP page. The FOR loop is a statement that prints "Hello
World" 10 times (MSDN n.d.).