• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is Enumeration act as stack?

 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
with this below part of script output is

"<LI><B>param1</B>:" +
request.getParameter("param1") + "\n"+
"<LI><B>param2</B>: "+
request.getParameter("param2") + "\n"+
"<LI><B>param3</B>: "+
request.getParameter("param3") + "\n"+

for URL-http://localhost:8080/servlet/ThreeParams?param3=3¶m2=2¶m1=1

param1: 1
param2: 2
param3: 3

this is correct.
but when I use enumeration then it is giving

Enumeration param_names = request.getParameterNames();
while (param_names.hasMoreElements())
{
String param_name = (String) param_names.nextElement();
String param_value = request.getParameter(param_name);
out.println(" <LI><B>"+param_name+"</B>: "+ param_value +"\n");
}
output is

param3: 3
param2: 2
param1: 1

is Enumeration act as stack?


Yamini.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your example, doesn't param3 come first, param2 second, then param1? So the display order is the order of the parameters. Isn't this FIFO, as opposed to LIFO (stack)?
 
yamini nadella
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for both I kept param1=1¶m2=2¶m3=3. then I got in reverse order with enumeration.
 
reply
    Bookmark Topic Watch Topic
  • New Topic