aspose file tools*
The moose likes JSP and the fly likes getParameterValues(String) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "getParameterValues(String) " Watch "getParameterValues(String) " New topic
Author

getParameterValues(String)

Zeina Afif
Greenhorn

Joined: Jul 19, 2001
Posts: 22
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

Joined: May 10, 2001
Posts: 3244
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


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getParameterValues(String)
 
Similar Threads
Difference between ArrayList and Vector
How To Make an Array from Multiple Selection of a Drop-Down Menu (or Scrollable List)
Java Collections 2
Casting question
Two dimensional data structures?