Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getInitParameterNames();

 
Zach Burke
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Trailboss
Pie
Posts: 21447
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And that's bad?
 
Zach Burke
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: frank@efsol.com http://www.io.com/~efficacy ]
[ At Work: frank.carver@bt.com tel +44 (0)1473 227371 ]
 
Kalyan Ayyagari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't help noticing the timestamp of the posts on this perticular thread - February 1999???
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. I find old threads topping in several forums..looks like some bug in javaracnk implementation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic