Use of Collection API in servlets


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Use of Collection API in servlets

  1. #1
    Christian Sellberg Guest

    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



  2. #2
    Paul Clapham Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center