title: Create a single instance of HashMap in Java throughout the session
body: <p>I am working on a project wherein I need to store a set of keys and values throughout the session of the program execution. Meaning when the server is up, I want to have a map which stores data and is same for multiple requests made in that session.</p>
  
  <p>So for creating this map, should I make a <strong>static</strong> Map or create a singleton bean for it and use <strong>autowiring</strong>? Which is better?</p>
  
  <p>I used the static map, but noticed that even after stopping the server and running it again, the map instance was having values from previous session, instead it should have been null in the beginning of the request. The objects were not getting destroyed properly. </p>
  
  <p>Does this behavior is improved if I'll use beans?</p>