Introduction to Server-side Scripting

Server-side scripts are discrete blocks of program code that execute on a web server (as opposed to a web client) computer. They are generally used to create dynamic web pages. This means that the page displayed to the user does not exist as a document on the server in its own right, and is only brought into existence in response to a user request. Often, a server-side script provides the interface between a web-based user interface and a database that resides on a web server.

Early server-side scripts were almost always C programs, Perl scripts or shell scripts which were accessed via the Common Gateway Interface (CGI). Today these scripts, together with scripts created in more recent web application programming environments such as ASP or PHP, can be executed directly by the web server itself, or through the use of server extensions. Direct execution is usually faster, as the involvement of a separate interpreter is not required. The following technologies are currently used to create web applications using server-side scripts:

Server-side versus client-side scripting

Server-side and client-side scripting serve very different purposes. Client-side scripting is executed on the client computer, and usually runs as interpreted program code within the browser. It can be used to make web pages more interactive (for example by creating rollover effects), to determine which user-agent (browser) is running on the client computer, or to validate form data before it is sent to the server to be processed by a server-side script. One of the most important differences is that the factors that determine the effectiveness of client-side scripting will be largely outside the control of the application developer. Although most client-side scripts are written in an ECMAScript-compliant language such as JavaScript, some are written in a proprietary scripting language that will not work correctly in all browsers. Furthermore, older versions of popular browsers may not support client-side scripting at all, while newer versions offer the user the option of turning off support for scripting.

Server-side scripting can be used to process form information submitted by a client, query or update a server-side database, and dynamically generate web pages that can be displayed in the user's browser. All the necessary processing is carried out on the server, and is therefore entirely under the control of the application developer. The web content generated and sent to the client will be displayed correctly, regardless of the type of browser in use, or any restrictions imposed by a user-defined browser configuration. In fact, the server-side script can use the environment variables contained within client requests to determine which user-agent sent the request, and if necessary modify the format of the dynamically generated response accordingly. When deciding whether to use client-side or server-side scripting, therefore, consider the extent to which you need to control the processing being carried out by the script. The main benefit of server-side scripting is that you have far more control over the behaviour of your application. The main disadvantage is that the server will have a greater overall workload, and the user will experience significant delays between initiating a request and receiving a response.