Scenario:
A user fills out my JSP form by selecting his/her state from a drop down list. (The drop down list is populated from a database)
The user hits "Next" on my form to go to the next page.
The user goes back to the previous page by hitting "Back" on my form.
Problem:
The State field does not repopulate with what the user selected.
Question:
How do you repopulate the field with what the user selected? (I tried using http sessions). I have included my code below:
Current Code:
<td><select name="State" tabindex="6">
<option>--</option>
<% for(int i=0; i<stateDDL.size()-1; i++){
String state = stateDDL.get(i).toString();
i++;
String stateVal = stateDDL.get(i).toString();%>
<option value=<%=stateVal%>><%=state%></option>
<%
} %>
</select></td>
Note*: stateVal represents the value that is being sent to the database (i.e. "AL") state represents the string the user sees in the drop down menu (i.e. "Alabama")