Handling Client Request Form DataPresentation Transcript
Handling Client Request Form Data
The Role of Form Data
If you have ever used the search engine visited an online books store tracked stocks on the Web or asked a Web- based websites for quotes on the tickets, you have probably seen funny looking. URLs like http://host/path?user=Marty+Hal&origin=bwi&dest=sfo . The part after the ? Is known as form data (or query data) and is most common way to get the information from the web page to a server side program. Form data can be attached to the end of URL after the question mark for GET request, form data can be sent to the server on different line for PoST request. Here are the basics:
1) Use the Form element to create the HTML form . Use the ACTION attribute to designate the address of the servlet that will process the results; you can use abosulate or relative URL For:
Use input element to collect user data.Place the elements between the start and end tags of the form element given each input element a name .Textboxes are most common input parameter created with the following:
< INPUT TYPE =‘TEXT’ NAME=“….”/>
Place the submit button near the bottom of the form: For example,
When the button is pressed the URL designated by the form’s ACTION is invoked . With GET request a question mark and the name value paurs are attached to the end of the URL where the name comes from nmae attribute in the HTML input elements and the values come from the end user.
Reading Form Data From The Servlet
One of the nice feature of the servlet that all of the form parsing handled automatically.You call the request.getParameter to get the value of Form parameter.
You can call request.getParametValues() if the parameter appears more than once.