It depends on what your requirements are. If you need a high performance, low latency solution that depends on a lot of small tasks, you may go with a structure similiar to what you describe. The most common solutions, in Java, PHP, and C# don't default to this though.
Most web application depend very heavily on databases - most of them so much so that pages could not render without at least one call. Obviously you do not want to expose your database publicly, for several reasons:
- Security (as Oded mentions) - you definitely do not want to expose your network publicly! Ideally the only interface to your systems from the outside should be https to your server.
So, when you need a database, you use languages that do play nice with them like Java, C#, PHP, etc. The easiest way to generate a page turns out to be as follows: You use a templating language (most famously PHP, but JSP and ASP are two other very common languages) to construct the page. The language provides constructs that call out to other modules. In PHP this is commonly in the page or in another PHP file, using the MVC pattern. In JSP you use scriptlets or the JSP Expression Language. These other modules can to the heavy work of connecting to the DB, performing logic, and returning values to your view layer. The end result is a generated HTML page, rendered on the server and sent to the client.
When your database is on the same network as your page renderer, you get better performance as well. The client only has to do one request and receives a page - you may need to do 10-15 DB requests before you have all the information the user needs. A latency of milliseconds on your network would be seconds to minutes if the client had to do them all.