What is the proper way to use URL parameters?
My URL is this: http://localhost:8080/#pg5?testing=abc
In my code I try to get the value of testing using this line of code:
String value = com.google.gwt.user.client.Window.Location.getParameter("testing");
Unfortunately all this does is set my string to "undefined".
I thought perhaps it wasn't getting the correct URL but this code returns the proper URL:
String value = com.google.gwt.user.client.Window.Location.getHref();
I know I can parse the url to get my parameters, but I thought that's what getParamerter() was for.
Yes, that's what you should be doing. encodeURIComponent is the correct way to encode a text value for putting in part of a query string. but when it is decoded at the server, the parameters of url are interpreted as seperate parameters and not as part of the single url parameter.
GET parameters (also called URL parameters or query strings) are used when a client, such as a browser, requests a particular resource from a web server using the HTTP protocol. These parameters are usually name-value pairs, separated by an equals sign = .
url should be http://localhost:8080/?testing=abc#pg5 instead of http://localhost:8080/#pg5?testing=abc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With