You didn't find a nit, you just didn't read carefully enough.  What I said
was "You can however reuse the same enumeration variable"  which is the same
thing you said.
    (*Chris*)

----- Original Message -----
From: Lance Lavandowska <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 21, 1999 6:46 PM
Subject: Re: Enumeration for http parameters


> >loop.  You can however reuse the same enumeration variable like this:
> >Enumeration enum = request.getParameterNames();
> ><snip>
> >
> >while(enum.hasMoreElements()) {
> <snip>
> >}
> >enum = request.getParameterNames();
>
> Just to pick a nit, you are not reusing the same enumeration, rather
> you setting the same variable ("enum") to contain the same value
("request.getParameterNames()").  While effectively the same, these are
different, and I have long wished that one could "rewind" an enumeration:
> while(enum.hasMoreElements()) {
> <snip>
> }
> enum.rewindToBeginning(); // a long winded method name
>
> so I wouldn't have to reset the value of the enumeration...
>
> Sorry, you just hit a sore spot of mine,
>
> Lance
>
> -----Original Message-----
> From: Chris Pratt <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Tuesday, September 21, 1999 8:30 PM
> Subject: Re: Enumeration for http parameters
>
>
> >An enumeration allows you to run through a collection of objects.  Once
> >you've reached the end, it does not go back to the top.  If it did, you
> >wouldn't know when you reached the end and you'd have yourself an endless
> >loop.  You can however reuse the same enumeration variable like this:
> >
> >String name;
> >String value;
> >Enumeration enum = request.getParameterNames();
> >Hashtable hash = new Hashtable();
> >
> ><snip>
> >
> >while(enum.hasMoreElements()) {
> >       name = (String)enum.nextElement();
> >       value = request.getParameter(name);
> >       hash.put(name, value);
> >       System.out.println(hash.get(name));
> >}
> >enum = request.getParameterNames();
> >while(enum.hasMoreElements()) {
> >     name = (String)enum.nextElement();
> >     value = (String)hash.get(name);
> >     System.out.println(value);
> >     msg.println(name + ": " + value);
> >}
> >
> >    (*Chris*)
> >
> >----- Original Message -----
> >From: Message UK <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Tuesday, September 21, 1999 5:34 AM
> >Subject: Enumeration for http parameters
> >
> >
> >> Hello all. I have an email servlet which processes a form. I use an
> >> Enumeration to get the parameter names, the values of which I then put
> >into
> >> a hashtable (don't ask). When I get the values out again to output, I
find
> >I
> >> have to use a second Enumeration to get the parameter names. If I
don't,
> >> nothing is retrieved from my hastable. Does the Enumeration object
"empty"
> >> as the elements in it are retrieved? Thanks so much.
> >>
> >> Enumeration enum = request.getParameterNames();
> >> Enumeration enum2 = request.getParameterNames();
> >>
> >>
> >> file://we'll store the submitted parameters here
> >> Hashtable hash = new Hashtable();
> >>
> >> <snip>
> >>
> >> while(enum.hasMoreElements())
> >> {
> >>
> >>         String name = (String)enum.nextElement();
> >>         String value = request.getParameter(name);
> >>
> >>         hash.put(name, value);
> >>
> >>         System.out.println(hash.get(name));
> >>
> >> }
> >>
> >>
> >> <snip>
> >>
> >> while (enum2.hasMoreElements())
> >> {
> >> String name = (String)enum2.nextElement();
> >> System.out.println((String)hash.get(name));
> >>
> >> msg.println(name + ": " + (String)hash.get(name));
> >> }
> >>
> >>
> >>
> >> D Lampon
> >>
> >> ______________________________________________________
> >> Get Your Private, Free Email at http://www.hotmail.com
> >>
> >>
>
>___________________________________________________________________________
> >> 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
> >
>
>
___________________________________________________________________________
> 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