Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

storing a map in servletContext

 
Maharaj thak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I have a map stored in the servletContext.Will there be a slowness in performance if I access those variables in my .gsp files?Data from the map is read more than written to it.

Regards
Mauji thak
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think performance, so to speak will be your big problem. Yes it can be affected by the big problem that might occur storing a mutable Map in the ServletContext. And this has nothing to do with Groovy or Grails. So the ServletContext is a single instance per web application. So it is shared across the entire web application, and therefore many threads might be trying to read/update that one single Map you have stored. So now you have to make sure that your Map reading/writing is done in a threadsafe manner. That part of maybe having to synchronize on the Map or worse the ServletContext, that you might have contention and therefore slow down performance.

However, that is also not to say that 100% of the time this is a bad idea. It all depends.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic