| Author |
how to get queryParameter from Request?
|
ammu lu
Greenhorn
Joined: Jun 17, 2008
Posts: 3
|
|
hi, I have a small doubt regarding query string, i am getting the query parameter from the request, but for some special characters i am not able to get any String . for ex:%,&,+,\ etc., To get correct String for these character from the request what i need to do? can you please help on this? Thanks in advance.....
|
 |
Ashika Sharma
Greenhorn
Joined: Feb 17, 2005
Posts: 7
|
|
|
Use the java.net.URLEncoder class to encode all of your parameter values.
|
 |
James Ellis
Ranch Hand
Joined: Oct 14, 2004
Posts: 205
|
|
|
Expanding on that..if the request came to you via a GET or POST, it should already be encoded.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56201
|
|
Originally posted by James Ellis: Expanding on that..if the request came to you via a GET or POST, it should already be encoded.
Not necessarily. If the data was from a form submission, then yes, the data is automatically encoded. However, if a link with parameters was built in code (either client or server side), then the data needs to be properly encoded. That also applies to Ajax requests.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
zeba saj
Greenhorn
Joined: Jul 17, 2008
Posts: 4
|
|
If it is get method we can use encodeURIComponent("field name") in java script
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2552
|
|
Hi small wonder welcome to Javaranch, Your display name does not follow the Javaranch Naming policy. Please change it here.
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56201
|
|
|
"Dilshad", please check your private messages for an important administrative matter.
|
 |
 |
|
|
subject: how to get queryParameter from Request?
|
|
|