Server side vs Client side web programming
This page is part of Ron Mertens' web page guides.
When you surf the web, you use the browser to view pages. The browser is the "Server side" computer. In the background, there
is also the server, which 'prepares' the web page for you to see. Some of the computation takes place in the client, and some
takes place in the server. This is a short explanation that might help you later...
Basic HTML request scenario
The basic scenario is simple. You open up your browser, and point at some page, let's say 'http://www.site.com/somepage.html'. In this case, you simply
want to download a single, simple page from the internet.
The 'somepage.html' file is already present in the server, it was written in advance.
The web server gets your request, and simply sends you an HTML page. An HTML page is like a document. It includes some words, some formating (Such as where to
put underline or how to color the text), image links and such. Your browser receives this page, and displays it.
In this case, most (or almost all) of the work is done in the client side. It has to decode the page and display it correctly.
The server wasn't doing anything - just handing you the web page.
Server side computing scenario
Let's look at a more complex scenario. Let's say you log into Amazon.com
and search for a 'harry potter' book. Obviously the page that you get cannot be written in advance - it contains dynamic
content.
The server in this case receives your 'search' request, and then runs a server-side software that prepares the HTML page. This new, dynamic
HTML page is then sent to your browser to display. Your browser will not 'know' the the server used a software. It will not see
the code. For all it cares, it received a regular HTML page.
Client side languages
All web pages (well, almost) are written with HTML. HTML is a markup language, which basically allows you to format content, place images, tables, etc.
In recent years, new languages are coming up, which complement HTML -
- CSS - CSS is a language that helps you sperate content and formatting. It's not a programming language, but it helps
you define text and imaging formatting for your content more easily than HTML does.
- Javascript - A script language that helps you make your pages more 'dynamic'. Simple uses involve dynamic menus and effects. You
can write complicated software using Javascript, see the 'Asynchronous web' part below.
- Other scripting languages - there are more options for client-side scripting, such as VBScript. But these are less common
then Javascript
All of these languages are actually part of the HTML page, they just make it better. We'll discuss them later on.
Server side languages
There are lot's of server side languages. Most of them are used to the same purpose - to create software (an executable, or script) that
runs on the server side, and outputs a HTML page (perhaps with CSS and Javascript, too). Common languages include -
- PHP - An open source language, which seems to be the most popular server side scripting language today.
- ASP - Active Server Pages, Microsoft own language.
- ASP.NET - the new generation of ASP. It will run as a Dot Net runtime, on the server machine.
- JSP - Java server pages - like ASP, but written in Java.
These are the kind of languages that allow you to build complicated web sites, such as Amazon.com.
Usually they will interact with a Database to save and retrieve data. Common databases are MySQL for the open source world, SQLServer from Microsoft, and of course Oracle and all the rest.
Flash
Flash is the vector-graphics format by Macromedia. Some people like to use it on web pages to make them more 'pretty'. I personally don't like it... Pretty
almost always equals to 'annoying' when you are just looking for information. Search engines have a lot of problem with flash, so you'll be hindering your position in the search, and
some users simply do not have the flash plugin.
There are server-side packages today that allow you to create flash movies on the fly, which means that you could in theory build a complicated, dynamic web page
with a flash user interface.
Asynchronous web
Just to make things complete, there's a new generation of web sites that are quite different than what we discussed here. Basically, all the interface of regular
web pages is performed via links and forms in the HTML page. Every time you ask for a new page (like a search in amazon), then the server creates a new HTML page
and send it to you.
There are new pages that claim to be 'Asynchronous'. This means that in the browser you have an application, and not just a 'web page'. This application can
interact with the server whenever it wants. So for example, if you are using a web mail reader, you might recieve an indication that a new mail arrived without needing to
'refresh' your browser.
The prominent language (or environment, really) is called AJAX - Asynchronous Javascript and XML. Building such a web application is complex, but basically
it just uses Javascript as the language that makes your client application.
Google likes to use AJAX in its web pages. This means that they can create rich applications such as Google Calendar or GMail, that really look and behave like
desktop applications.
Summary
There are two kind of web languages -
- Client side - which means you download the code to your computer, and then your browser 'runs' it.
- Server side - advanced code that runs on the server and prepares you the pages to view in the browser, dynamically.
What's next?
Continue our web site building guide with writing a basic, static web page.