title: Struts2 - Session Troubles
body: <p>I make (thanks with some users on this portal) my application that implements SessionAware.</p>
  
  <p>This is my actual code :</p>
  
  <pre><code>public class UserManager extends ActionSupport implements SessionAware {
      private Map&lt;String, Object&gt; session;
  
      @Override
      public String execute() throws Exception {
          return SUCCESS;
      }
  
      public void setSession(Map&lt;String, Object&gt; map) {
          this.session=map;
      }
  
      public String checkLogin() {        
          session.put("loggedOn", true);
          return SUCCESS;
      }
  
      public String checkLogout() {
          session.clear();
          return SUCCESS;
      }
  }
  </code></pre>
  
  <p>And i check these variables on my .jsp :</p>
  
  <pre><code>&lt;s:if test="#session['loggedOn']!=true"&gt;
      DIV LOGIN
  &lt;/s:if&gt;
  &lt;s:else&gt;
      DIV LOGOUT
  &lt;/s:else&gt;
  </code></pre>
  
  <p>An easy piece of code. </p>
  
  <p>What i'd like to know is this :</p>
  
  <p>1 - the bean is (as default) request scoped. So when the request is finished it will be destroyed. But i see that, when i put a variable in the Map, it still alive on the server. How is possible? Is a variable of my Bean.</p>
  
  <p>2 - Who call the setSession method? I think the servlet, due to the fact I implements that interface?</p>
  
  <p>3 - I would like to detach about saving object/bean on a Session Object. I'd like to use the Bean session scoped (as for any kind of MVC framework). How can I do it on struts2?</p>
  
  <p>Hope you can make clear these questions :) Cheers</p>