Server-side scripts are run directly on the web server by the request, sent by the client-side application (browser). These scripts are used during the development of interactive websites that need guestbooks, polls or other software components that actively interface to databases or other data stores. Let us take a closer look at server-side scripts, their peculiarities and sphere of usage.
The notion of server-side scripts
Let us start with a small example. Let us assume, that your site has a certain protected area, that can be accessed by some user categories only (for example, by the administrators). To enter such area you should enter your personal information: username (login) and password, i.e. you should log in. After you have logged in, the content available for logged in users will differ from the content available for the rest of the visitors. How does it happen? When you press the “Log in” button in the authorization form, a request to the web server is formed. In order to fulfill this request, a server-side script is run on the server. It accesses the database, finds there an entry that corresponds to the client-side request and processes it according to a certain pattern. Therefore, the script generates the content of the page depending on the received information, i.e. dynamically, and the user receives the result of the script – the generated page.
To perform similar and many other tasks, server-side scripts usually access the databases controlled by various Database Management Systems (DBMS), such as Oracle, MySQL, Microsoft SQL Server, Firebird etc.
As opposed to client-side scripts, that are executed client-side, by the user's browser during the page load, server-side scripts require preliminary compilation. That is why the execution of server-side scripts requires special software, that is installed on web servers. The most widespread server-side languages are PHP, Perl, ASP.NET, Ruby. PHP and ASP.NET are the most popular among all server-side scripting languages. Let us take a closer look at these two languages.
PHP
PHP server-side scripting language was created in 1994. It was initially created as a set of Perl scripts called “Personal Home Page Tools”. Today different versions of PHP are used, the latest version is PHP 6. PHP is a recursive acronym, shortened for PHP: Hypertext preprocessor. As we have already mentioned above, this abbreviation originally meant Personal Home Page Tools. Though PHP was originally designed for creation of dynamic personal web pages, it now focuses mainly on server-side scripting. PHP can also be used for client-side GUI application and command-line scripting. For example, a lot of popular content management systems (CMS) are powered by PHP. Wordpress (the most popular blog publishing application used by over 13% of the 1 000 000 biggest websites) is one of them.
How to add PHP on a web page
PHP only parses code withing its delimiters – special tags. The most common delimiters are <?php {command list} ?>. Along with these tags (delimiters) you can also use additional variants, such as <? ?> and <script language="php"> </script>. You can insert a PHP code into an HTML page, just like JavaScript. You can also create a separate file with .php extension, that will be requested from a certain part of the initial HTML page, for example, during the processing of an event of pressing the button. You can edit PHP code either in a special editor, for instance, Adobe Dreamweaver, or in a common text editor, for example, Notepad and its variations.
ASP.NET
ASP.NET is a web application network developed and marketed by Microsoft. ASP.NET is the successor to an older technology, Microsoft ASP (Active Server Pages), and has a number of peculiarities. A code for ASP.NET can be written using any supported .NET language (CLI language – a language that conforms to the Common Language Infrastructure), for instance, C#, Visual Basic.NET and JScript .NET. ASP.NET has a speed advantage in comparison with scripting technologies; the code is compiled when its containing page is requested for the first time, then it is cached and executed from the memory during subsequent requests.
If you a going to work with ASP.NET, you will have to install special software – Microsoft Visual Studio, an integrated development environment (IDE), that includes a code editor. Having installed the program, create a new file – a web page. The main part of such file is a common HTML document with standard structure. At the very beginning of this document there is a line which contains ASP.NET directives. At the beginning of the file you can also see information about the programming language that is used in the module connected to this page (for example, C#), automatic connection of events of this page with functions that process these events, as well as the name of the module which contains the program code linked to this page. If a file has .aspx extension, it means, that it contains ASP.NET directives and must be executed by .NET Framework platform.
As opposed to PHP language, which supports various operating systems and database management systems (DBMS), ASP.NET mainly interacts with Microsoft products: Windows operating systems and Microsoft SQL Server or Microsoft SQL Server Express DBMS.
Why do web developers need server-side scripts?
The opportunities, provided by server-side scripts, are quite rich. For instance, server-side scripts can process information entered into forms, generate dynamic pages or send and accept cookies. With the help of server-side scripts you can create guestbooks, chats, polls, store password protected data. None of online shops can do without server-side scripts: they provide users with an opportunity to calculate the total cost of the purchase, modify his shopping cart, fix the time and date of the order etc. Moreover, server-side scripts allow to create content management systems (CMS) with built-in visual editors, forums etc (it has already been mentioned, but we would like to emphasize this fact once more).
Pros and cons of server-side scripts
The advantages of server-side scripts (as compared to client-side scripts) are the following:
- the source code of a server-side script is unavailable for view from the user's browser, therefore it is protected from hacking;
- server-side scripts allow to send data to the server and receive an answer;
- server-side scripts allow to interact with databases – the user does not have to download large amount of information on his computer;
- only the result of script execution is send to the user from the server – it allows to make the loading of the whole page much quicker;
- the user cannot disable execution of server-side scripts in his browser, therefore you can be sure that your web application will work correctly irrespective of the user's browser;
However, server-side scripts have certain disadvantages:
- before being executed, a server-side scripts must be compiled or interpreted by the server;
- the page must be re-loaded from the server – it means additional waiting time for the user;
- software for execution of server-side scripts may be paid, whereas client-side scripts do not need any additional software at all;
To sum everything up, we would like to emphasize that it is impossible to say which kind of scripts is better. Both server-side scripts and client-side scripts solve their own range of tasks. These groups of web programming technologies are not opposed, they rather supplement each other creating a full-grown interactive and functional web application.
TAGS
web programming,
scripts,
server-side scripts,
net framework,
website development,
dbms,
oracle,
mysql,
sql server,
firebird,
perl,
ruby,
aspnet |