When the web server receives a request to display a dynamic page, it transfers the page to a special piece of software that's in charge of finalizing the page. This special software is called an application server.
In the following diagram, we can see a schema for processing a request in a web server:
The application server, according to the request that has been made, executes a program in a certain programming language and returns an HTTP response, whose content is usually an HTML page.