Clients and Servers
Web applications are "programs" that run at the browser ("client") and
or web "server".
These programs are implemented via a number of technologies usually based on
the operating system, web browser, and web server. For example:
 | UNIX operating system (server)
 | Apache web server |
 | C, C++, Perl, PHP, Python, JSP (Java Server Pages), Java programming
languages that implement applications on the server. |
|
 | Windows
operating system (server)
|
 | Desktop client...
 | Web browser (Internet Explorer, Netscape) |
|
On top of all of this, databases play a crucial role in these applications.
The databases are found on the servers.
So, how do things work...
Let's start with the basic HTTP model (how web sites work)...
 | The web browser (client) requests information via HTTP from the web
server. |
 | The web server responds with the requested data (typically an HTML
file and associated files, e.g., graphics). |

Now imagine that we want to do something interesting such as...
 | The end user will enter data (e.g., about someone) into an HTML-based
form in a web browser. |
 | Submit that data to a web server (but make sure all of the data has
been collected). |
 | The web server invokes an application to store the submitted data to a
database. |
 | Send a message back to the client indicating that the input was
successful. |
How does this work?
- Client...Requests a web page from a server (starting or continuing)
the transaction).
- Client...A web page is displayed in the browser. The web page contains a form with the
appropriate data entry fields.
- Client...the user enters the data.
- Client...upon submission (e.g., clicking the HTML form submit
button), JavaScript client code is used to check that all desired fields are
completed (e.g., filled in, not all spaces, numbers when appropriate, proper
e-mail address). IF the form is properly completed, the data is
submitted, ELSE the user is notified to go back and finish/fix the data entry.
 | This process assumes that JavaScript (or other language/tool) is
available on the client. |
 | Can also be accomplished with Java applets, Flash, and similar tools. |
Client...sends the data to the server via HTTP.
 | May also involve a secure transmission via SSL. |
Server...receives the data via HTTP and invokes the appropriate
application.
 | Various implementation strategies are possible: scripts, servlets,
and executable applications. |
 | Scripts: code in HTML files (Perl, ASP, JavaScript); scripts are
in readable format; tend to be slower to write. |
 | Servlets: bytecode-based Java and similar technologies (very
closely related to executables). |
 | Executables: machine-language applications written in C, C++,
Java, Visual Basic, etc. |
Server...the application checks the data (which should be fine
because it was already checked).
Server...the application opens a database, and executes the data
transaction (the database is on the server).
 | Data transactions typically fall into four classes:
- Query (select) - retrieve data from a database (one or more
tables).
- Add (insert) - data is added to one table.
- Change (update) - data is modified for on or more records in a
single table.
- Remove (delete) - data is removed for one or more records in a
single table.
|
 | SQL and database application technologies are used to communicate
with the database environment. |
 | Other technologies will play a significant role here including
the use of ODBC, ADO, and other server/database support techniologies. |
Server...depending on the success of the database insertion, a
message is returned to the client.
 | The return message is typically a function of application generated
code based on error (or lack of error) messages from the database
transaction. |
Client...the success/failure of the database action is reported to
the end user.
Client and Server Interaction... many applications (e.g.,
e-commerce) often involve multiple communications between the client
and server requiring the management of "state information".
 | State information keeps track of variables (e.g., selected items
from a database). |
 | Two basic techniques: hidden fields and transparent cookies
(session variables). |
 | Hidden fields: added to forms and querystrings to track
information. |
 | Transparent cookies: generated by the server and stored on the
client in "short-term" cookies (disposed of after a time period or
termination of the browser). |
 | Hidden fields are dependable but can be awkward to manage. |
 | Transparent cookies depend on browser support (they can be turned
off). |
The following diagram displays the elements of the above interaction...

|