Dynamic webpages are at the heart of current websites. In this database query scenario, the web server generates the webpage contents before it sends the page to the client web browser. e only problem with the preceding query scenario is that the web server must include the database query result on the page before it sends that page back to the client. Unfortunately, neither the web browser nor the web server knows how to connect to and read data from the database. Therefore, to support this type of request, the web server’s capability must be extended so it can understand and process database requests. This job is known as a server-side extension.
A server-side extension is a program that interacts directly with the web server to handle speci c types of requests. In the preceding database query example, the server- side extension program retrieves the data from databases and passes the retrieved data to the web server, which in turn sends the data to the client’s browser for display. e server-side extension makes it possible to retrieve and present the query results, but more importantly, it provides its services to the web server in a way that is totally transparent to the client browser.
This procedure can be illustrated as:
1. The client browser sends a page request to the web server.
2. The web server receives and passes the request to the web-to-database middleware for processing.
3. Generally, the requested page contains some type of scripting language to enable the database interaction. e web server passes the script to the web-to-database middleware.
4. The web-to-database middleware reads,validates,andexecutesthescript.Inthiscase, it connects to the database and passes the query using the database connectivity layer.
5. The database server executes the query and passes the result back to the web-to-database middleware.
6. The web-to-database middleware compiles the result set, dynamically generates an HTML-formatted page that includes the data retrieved from the database, and sends it to the web server.
7. The web server returns the just-created HTML page, which now includes the query result, to the client browser.
8. The client browser displays the page on the local computer.
Currently, there are two well-de ned web server interfaces:
• Common Gateway Interface (CGI)
• Application programming interface (API)
The Common Gateway Interface (CGI) uses script files that perform specific functions based on the client’s parameters that are passed to the web server. The script file is a small program containing commands written in a programming language—usually Perl, C#, or Visual Basic. The script file’s contents can be used to connect to the database and to retrieve data from it, using the parameters passed by the web server. Next, the script converts the retrieved data to HTML format and passes the data to the web server, which sends the HTML-formatted page to the client.
The main disadvantage of using CGI scripts is that the script file is an external program that executes separately for each user request and therefore causes a resource bottleneck.
An application programming interface (API) is a newer web server interface standard that is more e cient and faster than a CGI script. APIs are more e cient because they are implemented as shared code or as dynamic-link libraries (DLLs). at means the API is treated as part of the web server program that is dynamically invoked when needed.
APIs are faster than CGI scripts because the code resides in memory, so there is no need to run an external program for each request. Instead, the same API serves all requests. Another advantage is that an API can use a shared connection to the database instead of creating a new one every time, as is the case with CGI scripts.
Although APIs are more e cient in handling requests, they have some disadvantages. Because the APIs share the same memory space as the web server, an API error can bring down the web server. Another disadvantage is that APIs are specific to the web server and to the operating system.
A web application server is a middleware application that expands the functionality of web servers by linking them to a wide range of services, such as databases, directory systems, and search engines. e web application server also provides a consistent run- time environment for web applications.