Reputation: 261
I just need little help, that is: many times i have seen http://www.xyz.com/index.jsp?etetet%rr^_frfwrw....
. I just wanted to know that what is this question mark ?etetet%....
coming after index.jsp
and why this is coming after index.jsp? Can somebody please explain what is the reason behind this?
I am also running my application like this: http://localhost:8080/myproject/index.jsp
How can i make my url to be looked like the above one i.e. http://localhost:8080/myproject/index.jsp?..eeqwe_%cdc...
I am using jsp, servlet and tomcat server.Any help is much appreciated.
Upvotes: 0
Views: 276
Reputation: 135
This is called in java a "query string" All elements passed after the ? character can be retrieve from request.getQueryString()
for example
test.jsp?myparam
the call to request.getQueryString() will return you "myparam"
Normally, you pass some parameters using key=value pattern separating by & character in order to use a parser to understand several parameters for example
test.jsp?param1=value1¶m2=value2
Be carefull, the length of the URL is limited to 255 characters
Upvotes: 2
Reputation: 5811
This is what is called URL query, or URL parameters. These parameters are accessible in your HttpRequest object like this:
String name = (String) request.getParameter("name");
For a URL like blah?name=Donkey
, the String variable name
will receive a 'Donkey'.
Unlike your example, the parameters commonly come as key-value pairs, ie. = and when more than one parameter is passed, the pairs are divided by ampersands:
blah?name=Donkey&quantity=10
Wikipedia: http://en.wikipedia.org/wiki/Query_string
Upvotes: 1