A query string
(sometimes also known as a search string
) is an optional
part of a URL
that goes after the file
name, and begins with a question (?
) mark. Query strings are used to pass variables from page to page on a web server
, thereby maintaining state on a stateless
For example, everything2 uses query strings to pass information on the current node, last visited node, etc... from one page to another.
They look something like this:
Most web-enabled programming languages have methods for obtaining the query string from a URL.
In ASP, this is accomplished through the Request.QueryString collection. Variables in the query string can be referenced through Request.QueryString(variable_name). Example (in VBScript) using the query string detailed above:
Response.Write Request.QueryString("node_id") & "<br>"
would result in the following output
to a browser:
would result in the following output to a browser
In Java, query string access is implemented in the java.net.URL class's getQuery() method. The method returns a String object containing the query string.