Chapter 11: Transactions on the Web
Lesson Goals
Students can create forms and write scripts that upload data to servers.
Lesson Outcomes
Students can:
- Create forms in Web pages that send data to Web servers.
- Write server-side applications that process form transactions.
- Write server-side applications that store data in and retrieve data from databases.
Introduction
The HyperText Transfer Protocol is a two-way communications channel. In Chapter 9 the primary download method of the protocol was used to GET
data from Web servers. The server’s URL was appended with a query consisting of key-value pairs, which the server interpreted to select data from a database to include in a responding Web page.
But Web servers can also be set up to listen for uploads of information using the POST method, and may store some or all of the uploaded data into a database. In addition, servers can respond to requests to modify or remove existing data from a database, with the methods PUT or DELETE, respectively.
For any of these transactions the Web server must use a programming language to process the request, interact with the database, and construct a Web page in response.
There are many open-source Web servers available, using a wide variety of programming languages to process uploaded data. The Apache HTTP Server is by far the most common, in use by more than 50% of all Web sites. It is very flexible, and is typically used with the programming languages Perl, PHP, or Python. A common configuration uses the open-source database MySQL, resulting in a “stack” of software called AMP. This is the default Web server on the team servers.
Another Apache project, the Tomcat Web Server, is specifically designed to use the programming language Java, and is used by GeoServer on the team servers.
In recent years a new open-source project called Node.js has exploded in popularity. It is a stand-alone JavaScript environment that comes with a Web server library, and is easier to use and lighter weight than Apache. So it is an ideal way to set up a transactional Web site without having to learn a new programming language.