title: holding variables in session scope without making them static?
body: <p>This is a rookie question, sorry.</p>
  
  <p>I developed a jsf-2 app (on Tomcat) which has a big controller bean declared in session scope.</p>
  
  <p>Now, the mistake I made was to put all session scoped variables in this bean as <em>static</em> variables, thinking they would not be shared between different instances of the app. But they are - static variables are shared across all instances of the app on a same JVM, which makes sense actually. Anyway, all my code is currently like that:</p>
  
  <pre><code>@SessionScoped
  @ManagedBean
  public ControllerBean{
  static private String aString = "session wide value for a string";
  //static getter and setter for astring
  
  }
  
  @viewscoped
  @ManagedBean
  public class OneRandomViewScopedBean{
  String oneString = ControllerBean.getAString();
  //operations on this string...
  ControllerBean.setAString(newValueForString);
  } 
  </code></pre>
  
  <p>Could I get pointers as to how I should refactor my code to remove the static variables in my ControllerBean? I suppose the solution is dead simple but I can't see it now.</p>
  
  <p>Note: I don't need to persist the data because the volumes are small and they can vanish after the app is closed</p>
  
  <p>Thx!</p>