aspose file tools*
The moose likes Servlets and the fly likes how to get queryParameter from Request? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to get queryParameter from Request?" Watch "how to get queryParameter from Request?" New topic
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: 61202
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 2716
    
    6

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: 61202
    
  66

"Dilshad", please check your private messages for an important administrative matter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get queryParameter from Request?