S
Saad Malik
I Everyone,
I had a quick question. I'm building a fairly simple server/client
application and I'm having a little problem:
My main Model/Controller class initially reads csv flat file and
creates about 100 JavaBeans (which HAS to be stored in a HashMap), and
then I store the HashMap into a session.
Then later I call dispatcher and forward the request to a JSP where it
extracts all of the beans.
while --- > HashMap.put(i,hashcar[j]
// assume hashCar is an HashMap containing 100 beans
session.setAttribute("hashCar",hashCar);
// then I forward to an JSP.
JSP PAGE
HashMap hashCar = (HashMap)session.getAttribute("hashCar")
// Use iterator on HashMap and iterate through the whole list...
Everything was perfect until I started debugging the application and
tried accessing the same webapp from same client successively in
multiple browser windows.
Then I get a ConcurrentModificationException from HashMap.
I was wondering if this kind of solution will fix it:
synchronize(hasCar)
// adding stuff
And also synchrnoize (hashCar)
in the JSP?
I had a quick question. I'm building a fairly simple server/client
application and I'm having a little problem:
My main Model/Controller class initially reads csv flat file and
creates about 100 JavaBeans (which HAS to be stored in a HashMap), and
then I store the HashMap into a session.
Then later I call dispatcher and forward the request to a JSP where it
extracts all of the beans.
while --- > HashMap.put(i,hashcar[j]
// assume hashCar is an HashMap containing 100 beans
session.setAttribute("hashCar",hashCar);
// then I forward to an JSP.
JSP PAGE
HashMap hashCar = (HashMap)session.getAttribute("hashCar")
// Use iterator on HashMap and iterate through the whole list...
Everything was perfect until I started debugging the application and
tried accessing the same webapp from same client successively in
multiple browser windows.
Then I get a ConcurrentModificationException from HashMap.
I was wondering if this kind of solution will fix it:
synchronize(hasCar)
// adding stuff
And also synchrnoize (hashCar)
in the JSP?