This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Also think about parameters with characters which would cause problems: http://localhost/show.jsp?type=bed&breakfast Your jsp will get two parameters: type=bed and breakfast= instead of type=bed&breakfast So you have to encode the & character.
Regards, Arjan
Vasim Patel
Ranch Hand
Joined: Apr 29, 2004
Posts: 87
posted
0
Thanks Arjaan
Not all characters are allowed in a url, like the space. This is an invalid url: http://localhost/My Testpage.jsp To get a valid url, you have to replace the space by it's encoding:
Vasim, URLs with spaces (and other special charactes) often come up when you are attempting to submit a form using GET with parameters. Suppose a parameter is the user name. I could easily wind up with something like this:
I would need to encode this to get rid of the space.
In Servlet terms, URL encoding doesn't refer to any sort of encrytion, obfuscation or escapes sequences. It refers to the enhancement of URLs so that browsers that have cookies disabled (or old browsers that that don't support cookies) can still maintain Java Sessions.
Customer surveys are for companies who didn't pay proper attention to begin with.
Albert M
Greenhorn
Joined: Aug 04, 2004
Posts: 5
posted
0
Originally posted by Tim Holloway: In Servlet terms, URL encoding doesn't refer to any sort of encrytion, obfuscation or escapes sequences. It refers to the enhancement of URLs so that browsers that have cookies disabled (or old browsers that that don't support cookies) can still maintain Java Sessions.
Whether you call it escaping or encoding is moot -- just don't call it encrypting, 'cause it's not.
The point is that special characters such as ?, & and = are used in the parsing of URLs, and if the parameter values contain these characters, the URL cannot be correctly parsed.
Encoding the URL parameters ensures that the URL can be parsed as intended. [ August 12, 2004: Message edited by: Bear Bibeault ]
e.g. if there was an & in a parameter value that would be interpreted as being the end of that parameter. Which could mess up the parsing of the other paramters. So paramter names and paramater values should always be url encoded when you are not certain of what they will contain.