★ wanayoo — archive 1999 http://wdvl.com/Authoring/Scripting/Tutorial/url_encoding.htmlNouvelle recherche | Portail wanayoo

Free ISP info!
logo

internet.com
Join the free
WDVL newsletter!

home

The GET Method

URL Encoding

  • Besides allowing web browsers (or you pretending to be one) to get documents from a web server, the GET method also implements a method for a web browser to send optional search parameters as well (it was used with ISINDEX HTML files originally).

  • Search parameters were encoded in a special way for processing by the web server.

  • Here is how encoding works:

  • The URL is differentiated from the first search parameter by a question mark (?). In other words, a URL generically looks like the following:

http://www.domain.com/dir/file?search parameters

  • Since you may want to have multiple search parameters, the GET method specifies that parameters are differentiated by placing an ampersand sign (&) between them. Thus, the encoded URL above becomes something like the following:

http://www.domain.com/dir/file?search1&search2&search3

  • Next, search parameters themselves are specified as "name/value pairs" separated by an equal sign (=) such as in the following example that sets the variable "lname" equal to "Sol" and the variable "fname" equal to "Selena":

http://www.domain.com/dir/file?lname=Sol&fname=Selena

  • Further, any spaces in the encoding string are replaced by plus signs (+) as in the following example:

http://www.domain.com/dir/file?name=Selena+Sol&age=28

  • Finally, any non-alphanumeric characters are replaced with their hexadecimal equivalents that are escaped with the percent sign (%). For example, a single quote character (') is encoded as %27 and a line break (which is a carriage return plus a line feed) is encoded as %0D%0A. Thus, we might see the following example that specifies that the variable pageName is equal to "Selena Sol's Page":

http://www.domain.com/dir/file?pageName=Selena+Sol%27s+Page

Exercise One
Table of Contents
Problems With the GET Method

Up to => Home / Authoring / Scripting / Tutorial

Instantly look up a "techie" word using Webopedia!!


internet.com
e-commerce
WebDeveloper Network


Earn cash for Clicks!

Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.

www.internet.com