Remarks
The servlet generates an HTML page with one form element for every snack.
- selectURL is a reference back to this servlet.
The submit button for each form sets a value for the parameter called selection: value set is name of the snack.
Crucially, every form element in the generated page also sets again any pre-existing values for selection, using hidden input elements:
void printHidden(PrintWriter out, String [] selections) {
if(selections != null)
for(int j = 0 ; j < selections.length ; j++)
out.println(<input type=hidden name=selection +
value=\ + selections [j] + \>) ;
}
The value of selections was returned by the the call to getParameterValues(), earlier in the servlet method.