<s1 title="Forms">

<p>Forms are, of course, the most important way of getting information
from the customer of a web site.  In this section, we'll just create a
simple color survey and print the results back to the user.</p>

<p>First, create the entry form.  Our HTML form will send its answers
to form.jsp for processing.</p>

<p>For this example, the <code/name="name"/> and <code/name="color"/>
are very important.  You will use these keys to extract the user's
responses.</p>

<example title='form.html'>

&lt;form action="form.jsp" method="get"&gt;

&lt;table&gt;
&lt;tr&gt;&lt;td&gt;&lt;b&gt;Name&lt;/b&gt;
    &lt;td&gt;&lt;input type="text" name="name"&gt;

&lt;tr&gt;&lt;td&gt;&lt;b&gt;Favorite color&lt;/b&gt;
    &lt;td&gt;&lt;input type="text" name="color"&gt;
&lt;/table&gt;

&lt;input type="submit" value="Send"&gt;

&lt;/form&gt;

</example>

<p>Resin keeps the browser request information in the
<code/request/> object.  The <code/request/> object contains the
environment variables you may be familiar with from CGI programming.
For example, it has the browser type, any HTTP headers, the server
name and the browser IP address.</p>

<p>You can get form values using <code/request.getParameter/> object.</p>

<p>The following JSP script will extract the form values and print them
right back to the user.</p>

<example title='form.jsp'>
Name: &lt;%= request.getParameter("name") %&gt; &lt;br&gt;
Color: &lt;%= request.getParameter("color") %&gt; 
</example>

</s1>



