-
Use of Collection API in servlets
Is it bad practice to use Collection classes like TreeMap to sort
corresponding key/values pairs if you want your servlets to be highly
scallable?! I mean can it fill up the memory if the garbage collector isn't
keeping up removing unused classes? I have a language dependent page where
users can choose their favorit language. Users can then select something and
see their choices in a dropdown menu. But the way their choices are spelled
is dependent on their language and I want to present their choices in
alphabetic order. That means I have to do the sorting dynamically. What I
have done know is just to create a TreeMap and fill it with the names as the
keys in the values of the dropdown as the values in the TreeMap. But is this
a bad way to use Collections? Will the performance suffer from such use of
Collection classes in servlets? It used for dropdownmenues with few and many
items. I create a new TreeMap instance each time the servlet is loaded.
Sincerely yours
Christian
-
Re: Use of Collection API in servlets
Since you are doing this in a servlet, I don't think there's much of a
garbage problem. You create a TreeMap, you set up your HTML, you send it to
the client. Then there's a huge pause (MILLIONS of microseconds!) while the
client considers what to do. If your servlet is going to be serving
thousands of clients at the same time, you might have a problem, but on the
other hand I don't know of any better way to sort things.
Christian Sellberg <sellberg@mac.com> wrote in message
news:B58F298E.525%sellberg@mac.com...
> Is it bad practice to use Collection classes like TreeMap to sort
> corresponding key/values pairs if you want your servlets to be highly
> scallable?! I mean can it fill up the memory if the garbage collector
isn't
> keeping up removing unused classes? I have a language dependent page where
> users can choose their favorit language. Users can then select something
and
> see their choices in a dropdown menu. But the way their choices are
spelled
> is dependent on their language and I want to present their choices in
> alphabetic order. That means I have to do the sorting dynamically. What I
> have done know is just to create a TreeMap and fill it with the names as
the
> keys in the values of the dropdown as the values in the TreeMap. But is
this
> a bad way to use Collections? Will the performance suffer from such use of
> Collection classes in servlets? It used for dropdownmenues with few and
many
> items. I create a new TreeMap instance each time the servlet is loaded.
>
> Sincerely yours
> Christian
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks