The getParameter() method is one of the HTTP request methods that is most often used to request resources from a server through a client (e.g., browser). Since the transmitted page contents or files are requested using URLs, indication of URL parameters is also important.
Communication between clients and servers on the Internet mostly takes place via the HTTP protocol (Hypertext Transfer Protocol). This enables a data exchange via request and response. A client could, for instance, be a user’s web browser; the server provides a HTML page that is loaded by the user’s browser. The two most commonly used methods to enable this kind of communication are GET and POST.
If a client uses the HTTP protocol on a webserver to request a certain resource, the client sends the server certain GET parameters through the requested URL. These parameters are pairs of names and their corresponding values, so-called name-value pairs. These are added to the URL with a “?” sign and tell the server which resources are meant. The name and value are always separated using an “=” sign.
The syntax is as follows:
Not just single but also multiple parameters as well as entire lists can be transmitted to the server. Here, the various parameters are separated using an “&” sign.
If the request is syntactically correct, the server sends a response. This initially contains certain status information about the request. This can, for instance, be whether or not the requested resource is available or when the request was made. The server does not first send the resource to the client but rather tells the client where the resource can be found. The browser then follows the instructions and asks for the resource from the server. This is when the browser finally loads the resource based on the location-based information provided to it by the server. The reason for this is that the HTTP protocol only allows one-way communication. Every request only receives one response.
Requests using the getParameter() have certain properties and disadvantages. Since the data is transmitted via the URL, it is advisable to only use the GET parameter to request files that are not security-relevant.
- Caching is possible
- Preservation in the browser history
- Saving as a bookmark is possible
- Unsuitable for use with sensitive files
- Length limitation (URL length)
- Its primary purpose is to obtain data
URLs with parameters are also referred to as dynamic URLs. By changing the parameters, a new URL results and the page contents can change dynamically. For example, if an online shop has added products on a category page and a user loads this page using a browser, the new products will also be displayed since the page’s URL also requests for the changed content using the GET parameter.
Importance for search engine optimization
The emergence of dynamic URLs when using getParameter() also has disadvantages.
Through the dynamics, it can happen that partly similar content is generated on several URLs. Duplicate content that results in this way has a negative effect on the ranking of the pages, which is why it is important to undertake certain prevention measures in terms of SEO. It is advisable to use the canonical tag such that the search engine crawler ignores the duplicate pages.
Another aspect that is important when using getParameter() is the readability of the URL. The parameters in the URL are usually cryptic and the names of the parameters are often inexpressive. There is the possibility to rewrite a dynamic URL to a descriptive URL using the rewrite rules in the htaccess-file. This is easier to read and more informative. It should be ensured that no information is lost in the process. The advantage of descriptive URLs is that they purportedly generate a higher click-through rate, which is very important for the SEO. Search engines can work with dynamic URLs but prefer descriptive URLs.
- ↑ HTTP Methods: GET vs. POST w3schools.com. Accessed on 05/08/2015