Java Reference
In-Depth Information
F
IGURE
4.1
Form HTML Page.
You should now complete the form and click the Submit button. The response you receive,
which will of course depend on your entries, should look something like that shown in
Figure 4.2.
How the
FormServlet
Works
Now that you have seen what the
FormServlet
does, let's take a look at how it does it. The
area we want to focus on is listed here:
// Get all the parameter names
Enumeration parameters = request.getParameterNames();
String param = null;
// Iterate over the names, getting the parameters
while ( parameters.hasMoreElements() ) {
param = (String)parameters.nextElement();
out.println(“<BOLD>” + param +
“ : “ + request.getParameter(param) +
“</BOLD><BR>”);
}