Problem with detecting the value of the drop down list on the server (servlet) side
- by Harry Pham
Client code is pretty simple:
<form action="DDServlet" method="post">
<input type="text" name="customerText">
<select id="customer">
<option name="customerOption" value="3"> Tom </option>
<option name="customerOption" value="2"> Harry </option>
</select>
<input type="submit" value="send">
</form>
Here is the code on the Servlet
Enumeration paramNames = request.getParameterNames();
while(paramNames.hasMoreElements()){
String paramName = (String)paramNames.nextElement(); //get the next element
System.out.println(paramName);
}
When I print out, I only see, customerText, but not customerOption. Any idea why guys? What I hope is, if I select Tom in my option, once I submit, on my servlet I should able to do this: String paramValues[] = request.getParameterValues(paramName); and get back value of 3