I get output as name2 name1 . Why is line seperator not taking any effect.
Do "view source" on the browser page. You should see two lines. In HTML \n is just a space. To display a new line, use <br>.
Originally posted by joshua antony:
And why is the order in the output different I mean name2 and then name1 and not the other way round.
Enumeration returns elements in the order supplied to it by the underlying Collection. The servlet specification makes no statements about that Collection. It does return the elements is some order, just not in the order you expected.
My guess is that it uses some HashMap to store paramname - paramvalue pairs and returns a Set (probably a HashSet) of parameter names using map.keySet(), which in turn is the underlying collection for the Enumeration. If you really want to know the algorithm which is used by HashSet for returning elements, you have to look at HashSet source because the API doesn't specify (and thus, guarantee) it.