The moose likes Servlets and the fly likes  getInitParameterNames(); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark " getInitParameterNames();" Watch " getInitParameterNames();" New topic


Zach Burke

Joined: Feb 18, 1999
Posts: 3
Hi ,
I have a servlet that uses this method to get the Names of the Parameters.
However it doesn`t seem to write the parameters to a file in order as they appear on the web page
paul wheaton

Joined: Dec 14, 1998
Posts: 20972

And that's bad?

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Zach Burke

Joined: Feb 18, 1999
Posts: 3
Well is there any particluar reason that they are written to file out of order,as I`d like to know what I may be doing wrong .
Or is this a normal thing.?
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
This is well known behaviour. The key thing to remember is that parameters, be they init parameters or from any other source, are stored internally as a Hashtable. [don't be surprised if seems they are actually stored in a Dictionary or a Properties, they're the same thing ]
Now the key thing about a Hashtable is that it is optimised for fast and simple retrieval of single entries, and part of the cost of that is that the order of the entries is lost. In cases which really need a Hashtable which preserves ordering, there is a new data structure as part of the Java 2 collections API.
In this case though, yes it is normal for them to come out in a different order, but this is OK, because the order shouldn't be important to your code.
Please let me know if the order is important, and we can sort out a solution for you here.

Frank Carver
[ Personal: ]
[ At Work: tel +44 (0)1473 227371 ]

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Kalyan Ayyagari

Joined: Aug 04, 2003
Posts: 5
I couldn't help noticing the timestamp of the posts on this perticular thread - February 1999???
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

Yes.. I find old threads topping in several forums..looks like some bug in javaracnk implementation

I agree. Here's the link:
subject: getInitParameterNames();
It's not a secret anymore!