Web applications

A web application is a special form of client-server application where we have a client that interacts with a user in the form of a web page. The server is responsible for producing the results the user will see and to accept and process the input from the user.

This process works something like this:

  1. Imagine that you visit a website and are prompted to log in. You enter your username and password. When you press the Log in button, the information you entered is sent to the server:

    Figure 3.5 – When logging in to a web application, your credentials will be sent to the server

  2. The server requests the information stored in a database about this user:

    Figure 3.6 – The web server requests the user information stored in a database

  3. The database returns the information it has for this user. Note that usually, the password will not be stored in plain text as illustrated here, but for clarity, we ignore that in this scenario:

    Figure 3.7 – The database returns the information

  4. The server application now verifies that the username and password are correct. If they are, it then produces a web page for this user and transmits it to the client's computer so that a web browser running on this computer can display this page:

Figure 3.8 – The server produces a web page and transmits it to the client

Let's see what this means if we want to create our very own social network.

Example of a social network

You would need to create both the client and the server part of this application. First, the user needs to log in. To do this, the client will ask the user for their credentials. The client will then send the username and password to the server, and the server will verify if the information is correct. The result will be sent back to the client. If the login fails, the user will be asked to try again. If it is successful, the user will see the main window with all the posts from friends and relatives.

It might feel like there is some magic going on here, because how did we get the most recent post your uncle did 5 minutes ago on the other side of the world?

Your uncle uses his client to create his post. The information about this post is sent to the server, which stores it in a database. When you log in, the server asks the database for all users you are connected to, and among them, it finds your uncle. Then the server checks if your uncle has made any recent posts and then finds his post. This post is now part of the result, together with posts from other friends, that is sent to you:

Figure 3.9 – Your uncle posts a new status update that gets included in your feed

Next, we will see how these apps are unique.

What makes web applications unique?

As we have seen, a web application is more-or-less just a client-server solution, but there is a twist that makes it not just a client-server application, and that is how the client interacts with the user.

If we think back to the client-server applications we talked about previously, the chat and email programs had been designed as standalone applications. This means that we have a program on our computer that we can start. That is not the case for our social network application. When users want to access it, they will start a web browser and navigate to the server's address. We can say that the web browser is a general-purpose client as it is not made to serve one solution but can be used to access any page on the web, our social network being one of them.

We will still need to design what this page will look like and what information will be displayed to the user, but the client usually has very little program logic built into it. The logic of our application is done on the server side, and it's the server that will produce the pages the user sees. They are transmitted to the client, which is the user's web browser, which then displays the result.

Next, we'll look at mobile applications.