web.xml - context-param not in order

2003-03-26 Thread David Thielen
Hi;

When I retrieve the param-name/param-value pairs from web.xml via:
Enumeration en = pageContext.getServletContext().getInitParameterNames();

It does not return them in the order they appear in web.xml. Is random order just part 
of the API definition?

thanks - dave

Re: web.xml - context-param not in order

2003-03-26 Thread p niemandt
Hi;

You are not guaranteed the order of the elements when using an
enumeration. This has more to do with basic data structures than with
the API. You would need to use a container that has a guaranteed order,
should you so wish.

This has to do with the dynamic nature of enumerations: They need to be
able to expand to store an unspecified amount of data. Should the
requirement enforce ordering on as well, you would loose the speed of
the enumeration.

You can always run through the enumeration, store this in an ArrayList,
and run Arrays.sort() on that, assuming that all the elements are
Comparable. Comparable - You must be able to call ElementA  ElementB
without getting a cast exception.

Have a look at the Java Collections Framework.


hth,
Paul

On Wed, 2003-03-26 at 21:55, David Thielen wrote:
 Hi;
 
 When I retrieve the param-name/param-value pairs from web.xml via:
 Enumeration en = pageContext.getServletContext().getInitParameterNames();
 
 It does not return them in the order they appear in web.xml. Is random order just 
 part of the API definition?
 
 thanks - dave
-- 
p niemandt [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]