Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is Enumeration act as stack?

 
yamini nadella
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • 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.
 
Adrian Pang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
for both I kept param1=1¶m2=2¶m3=3. then I got in reverse order with enumeration.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic