Dynamic Content
A server that serves only static content is useful, but there is much more that can be done. An HTTP server can deliver content depending on a more granular request, which is done by passing some parameters to the server. There are many ways to do so, but one simple way is to pass parameters to a querystring
. If the URL of the server is:
http://localhost:8080
We can then add something like:
http://localhost:8080?name=john
Here, the part ?name=john
is called a querystring
as it is a string representing a query. In this case, this querystring
sets a variable called name
with a value of john
. This way of passing parameters is generally used with GET
requests, while a POST
request will generally make use of the body of the request in order to send parameters. This does not mean that a GET
request does not have a body but is not the standard way to pass parameters to a GET
request. We will begin by looking at how to accept parameters for a GET
request, as this...