Java Reference
In-Depth Information
C HAPTER 7: R ESPONDING TO F ORMS
• Understanding Forms
• Responding to a Form with HTTP GET
• Responding to a Form with HTTP POST
• Sending Files with HTTP Upload
Most web sites make use of forms. Forms allow web sites to gather information from a
user. Because forms are very important to websites, it is also very important that an HTTP
programmer knows how to use Java to interact with forms.
This chapter will show you how to work with the forms you will encounter on web sites.
You will see how to work with basic forms that include text, buttons and other controls. You
will also be shown how to use multipart forms, which allow the user to upload files to the web
server.
I will begin with a review of how forms are constructed.
Understanding HTML Forms
HTML forms are contained in HTML documents. The HTML form occurs between the
beginning <form> and ending </form> elements. Inside of the form, various <input>
and other elements allow an assortment of controls to be used with the form.
To see a form in action, load the following URL in a browser. This form demonstrates
most of the controls that can be added to a form.
http://www.httprecipes.com/1/7/input.php
This form contains a variety of controls and shows what HTML forms are capable of. You
can see this form in Figure 7.1.
 
Search WWH ::




Custom Search