handling multiple select in JSP

Hi,

When I use request.getParameters to read from values passed in a multple select form element, I only ever get the first element. How do I handle multple select elements in jsp?

Example:

My HTML form:

<html>

<body>

<form name="testForm" method="post" action="testJSP.jsp">

<select name="testList" multiple="true">

<option value="1">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

</select>

<input type="submit">

</form>

</body>

</html>

--

My JSP action page:

<%

String sValue = request.getParameter("testList");

%>

<html>

<body>

<%

out.print(sValue);

%>

</body>

</html>

-

No matter how many values I select in the select box, the only value that will ever get printed out is the first selected value.

Using HTTPWatch, it seems that all values are passed independantly, with the same parameter name. (e.g. testList: 1, testList: 2, testList: 3) instead of a comma delimited string (1,2,3).

How can I handle this?

Thanks!

[1320 byte] By [ask_asoka] at [2007-11-26 12:37:27]
# 1
use getParameterValues() to get an array of all selected options.
gimbal2a at 2007-7-7 16:04:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
request.getParameterValues(String paramName) returns a String[] of all the selected values for a given parameter.
stevejlukea at 2007-7-7 16:04:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...