If you need just-in-time pages (dynamically-created pages that don’t exist before the request) and the ability to write/save data on the server (which means writing to a file or database), you can’t rely on the web server alone.
1 Dynamic content
The web server application serves only static pages, but a separate “helper” application that the web server can communicate with can build non-static, just-in-time pages. A dynamic page could be anything from a catalog to a weblog or even just a page that randomly chooses pictures to display.
When instead of this:
You want this:
Just-in-time pages don’t exist before the request comes in. It’s like making an HTML page out of thin air.
The request comes in, the helper app “writes” the HTML, and the web server gets it back to the client.
2 Saving data on the server
When the user submits data in a form, the web server sees the form data and thinks, “So? Like I care?”. To process that form data, either to save it to a file or database or even just to use it to generate the response page, you need another app. When the web server sees a request for a helper app, the web server assumes that parameters are meant for that app. So the web server hands over the parameters, and gives the app a way to generate a response to the client.