Results 1 to 1 of 1
Thread: URL Conventions with Form Data
- 11-13-2011, 07:59 PM #1Member
- Join Date
- Nov 2011
- Rep Power
URL Conventions with Form Data
When you look at the URL in your web browser if you are using a search engine or on a retail site, you will notice URLs http://host/path?user=James+Rogers&s...rish&sub=music. The part after the question mark (i.e., user=James+Rogers&subj= folk&sub=irish&sub=music) is known as form or query data and is the most common way to get information from a Web page to a server-side program. Form or query data can be attached to the end of the URL after a question mark, for GET requests, or sent to the server on a separate line, for POST requests. (Note that there was an urban myth of 256 characters for URIs on GET requests but this was never true and only a limitation caused by some server implementations).
With URLs such as the one shown above, extracting the needed information from this form data is using CGI programming is trying if not extremely difficult. Consider that you have to read the data one way for GET requests (through the QUERY_STRING environment variable for CGI) and for POST requests (through reading the standard input in traditional CGI). Then you have to divide up the pairs by the ampersands, then separate the parameter names (via the equal signs) from the parameter values. Finally, you have to URL-decode the values. The easy ones to deal with are alphanumeric characters as they are sent unchanged, but other characters need to be converted to various character strings. On the server-side program the process is reversed. Look at one of my previous tips on how servlets do parse query strings automatically and provide you with the parameters in a easy to use manner.
- By realmadrid_000 in forum AWT / SwingReplies: 8Last Post: 10-03-2010, 10:45 AM
- By vishalkrsrivastava in forum Java AppletsReplies: 10Last Post: 08-12-2009, 05:02 PM
- By Srikala in forum JavaServer Faces (JSF)Replies: 2Last Post: 07-16-2009, 10:06 AM
- By the swan in forum AWT / SwingReplies: 3Last Post: 04-14-2009, 07:14 PM
- By vk_satheesh in forum New To JavaReplies: 0Last Post: 09-19-2008, 01:48 PM