Problem with detecting the value of the drop down list on the server (servlet) side

Posted by Harry Pham on Stack Overflow See other posts from Stack Overflow or by Harry Pham
Published on 2010-03-31T01:54:11Z Indexed on 2010/03/31 2:13 UTC
Read the original article Hit count: 383

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about jsp

Related posts about servlet