• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getParameterValues(String)

 
Zeina Afif
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form that has parameters with mixed multiple and single values. It is used to create an SQL statement for search.
Is there a way to find out if a Parameter has more than one value in order to use getParameterValues(String) instead of getParameter(String)?
Here's my code:
Vector vParams = new Vector();
Enumeration enum = request.getParameterNames();
while (enum.hasMoreElements()) {
String x = (String)enum.nextElement();
ArrayList aParamValue = new ArrayList();
if((request.getParameter(x) != null) && !(request.getParameter(x).equals(""))){
aParamValue.add(x);
aParamValue.add(request.getParameterValues (x));
vParams.add(aParamValue);
}
}
Thanks for any help!
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zeina
getParameterValues() returns an array of Strings. If there is only one value then the array only has one element. So you can just check the size of the array that is returned and then handle it apporpriatley based on the size.
hope that helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic