> -----Original Message-----
> From: David Mossakowski [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 03, 2002 10:23 PM
> To: [EMAIL PROTECTED]
> Subject: Re: req.getParameterMap()?!?
>
>
> How about enumerating through a request.getParameterNames and getting
> values by calling request.getParameter?
>
> come to think of it why are you first calling a _dismantling_
> method and
> then manually putting the query together?
>
> how about calling request.getQueryString?
>
Because it's a POST request, and getQueryString() doesn't return name/value
pairs from the POST body. getParameterNames() appears to consolidate both
actual query string pairs with any more found in the body. It seemed like
the easy way to go, but I've never seen a method return something where you
had to check the instanceof to know how to operate on it.
Jay
> d.
>
> Jay Burgess wrote:
> > 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