Ahh, I think you need to look a little closer at those definitions, I
believe what you'll find is actually this:

Enumeration ServletRequest.getAttributeNames()
Enumeration ServletRequest.getParameterNames()
Enumeration ServletConfig.getInitParameterNames()
Enumeration HttpServletRequest.getHeaderNames()

String[] ServletRequest.getParameterValues(String key)

Notice that all the xxxNames() methods return an enumeration over a set of
Keys (or names).  The one xxxValues() method returns the (possibly numerous)
values for a single key.  So you might see something like this:

Enumeration enum = request.getParameterNames();
while(enum.hasMoreElements()) {
  String key = (String)enum.nextElement();
  String[] vals = request.getParameterValues(key);
  for(int i = 0;i < vals.length;i++) {
    out.println(key + '[' + i + "] = " + vals[i]);
  }
}

So the spec uses Enumerations for Keys and Strings or Arrays of Strings for
values.
  (*Chris*)

----- Original Message -----
From: "David M. Karr" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 15, 2002 8:11 PM
Subject: [SERVLET-INTEREST] Curiousity: return types of various "get..."
methods in servlet spec


> I'm curious what the rationale was for certain collection return types in
some
> servlet (2.3) specification methods.
>
> All of the ones I found in the spec return Enumeration, except for one,
which
> returns an array of String.  What was the rationale for the one oddball?
I can
> see that all the others get a list of "names" and the odd one returns a
list of
> "values", but I don't see how that would make a difference.
>
> These are the ones I found (I may have missed some):
>
> Enumeration ServletRequest.getAttributeNames()
> Enumeration ServletRequest.getParameterNames()
> Enumeration ServletConfig.getInitParameterNames()
> Enumeration HttpServletRequest.getHeaderNames()
>
> String[] ServletRequest.getParameterValues()
>
> --
> ===================================================================
> David M. Karr          ; Java/J2EE/XML/Unix/C++
> [EMAIL PROTECTED]   ; SCJP
>
>
___________________________________________________________________________
> 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
>

___________________________________________________________________________
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

Reply via email to