title: Storing object in session - struts2
body: <p>Hi I have something like this in struts.xml</p>
  
  <pre><code>   &lt;action name="LoginAction" class="controller.LoginAction"&gt;
                  &lt;result name="error"&gt;/Error.jsp&lt;/result&gt;
                  &lt;result name="success"&gt;/Wizard.jsp&lt;/result&gt;
      &lt;/action&gt;
  </code></pre>
  
  <p>Edited:</p>
  
  <p>Upon successful execution of <code>execute</code> in the action the next page has data which it accesses using the request scope. How can i store the same data in session scope instead?</p>
  
  <p>I read that <code>HttpServletRequest</code> object is passed as a parameter to the <code>execute()</code> method in a Struts action, and I can always retrieve the <code>HttpSession</code> object by using the <code>request.getSession()</code> and attaching data to it.</p>
  
  <p>So if I am using something like this in <code>controller.LoginAction</code></p>
  
  <pre><code>public String execute(HttpServletRequest req) {
      ...
  }
  </code></pre>
  
  <p>Do I have to change <code>struts.xml</code>? <code>execute</code> does not get called when <code>HttpServletRequest</code> is added as a parameter. </p>
  
  <pre><code>   &lt;action name="LoginAction" class="controller.LoginAction"&gt;
                  &lt;result name="error"&gt;/Error.jsp&lt;/result&gt;
                  &lt;result name="success"&gt;/Wizard.jsp&lt;/result&gt;
      &lt;/action&gt;
  </code></pre>
  
  <p>Also is using session this way the best method ? I am trying to familiarize my self with the struts method.</p>