I want to build a String version of my request parameters based on the
HashMap returned by getParameterMap(). I'm amazed that I have to do the
"instanceof" check below. Can someone confirm that this is the
requirement? (It doesn't work otherwise, and it's not clear to me why
getValue() doesn't just always return an array.)
Iterator iter = req.getParameterMap().entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
Object obj = entry.getValue();
if (obj instanceof String) {
params.append("&").append(key).append("=").append((String)
obj);
}
else { // else it must be an Array
String [] values = (String []) obj;
for (int i = 0; i < values.length; i++) {
String value = values[i];
params.append("&").append(key).append("=").append(value);
}
}
}
Thanks.
Jay
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html