title: Spring mvc portlet @sessionAtribute
body: <p>Hello would need a little help.</p>
  
  <p>I'm working with Spring and portlets, my problem is that I have 2 tabs handled by two different controller with 2 beans. What I need is to display data from the bean of the first controller in the render phase of the second controller.</p>
  
  <p>I try to do as follows:</p>
  
  <p>This is the controller for the first tab where I collect the necessary values ​​and generated a request with them.</p>
  
  <pre><code>@Controller
  @RequestMapping(ServletContextKeys.SC_VIEW_MODE)
  //This is my bean session
  @SessionAttributes(salarioBean)
  public class AltaSalarioFSOPortletController extends BaseController {
  
  private SalarioBean salarioBean;
  
  //With this method generated the request to display the data in the other controller jsp
  @RequestMapping(params = ACTION_CAMBIA_TAB)
  public final String doRenderTab(@ModelAttribute(value = "SalarioBean") SalarioBean salario, Errors errors, RenderRequest renderrequest, PortletSession portletSession) {
  
      //retrieve the bean managed by Spring in session
      SalarioBean salarioSessionBean = (SalarioBean) portletSession.getAttribute(salarioBean);
  
      ImputacionBean imputacionBean = new ImputacionBean();
      ....Insert data on imputacionBean
  
      //generated the request to display data in jsp handled by another controller
      renderrequest.setAttribute(imputacionBean,imputacionBean);
  
      //redirected to jsp
      return jsp_tab2;
  }
  </code></pre>
  
  <p>With this controller with it to display data in jsp, but my problem comes when trying to generate the same data when click-on the other tab. So I try to do with this method render in another controller:</p>
  
  <pre><code>@Controller
  @RequestMapping(ServletContextKeys.SC_VIEW_MODE)
  @SessionAttributes(imputacionBean)
  public class AsociarCostesSalarioAlumnoPortletController extends BaseController {
  
  private ImputacionBean imputacionBean;
  
  @RequestMapping(params = ACTION_ASOC_COSTES_SALARIO)
  public final String doRender(@ModelAttribute(value = "ImputacionBean") ImputacionBean imputacionSalarioAlumno,Errors errors, RenderRequest renderrequest,SessionStatus status) {
  
      justifSessionBean = (SalarioBean) renderrequest.getPortletSession().getAttribute(salarioBean);
  
      ImputacionBean imp=(ImputacionBean) justifSessionBean.getImputaciones().get(0);
  
  renderrequest.getPortletSession().setAttribute(imputacionBean,imp);
  
      setJustificanteAsociarCostesSalarioAlumno(imp);
  
      setRequestParameters(renderrequest, imp);
  
      return jsp_tab2;
  }
  
  @Override
  public final void setRequestParameters(RenderRequest renderrequest, Object object) {
  
      ImputacionBean imputacionSalarioAlumno = (ImputacionBean) object;
  
      renderrequest.setAttribute(imputacionBean, imputacionSalarioAlumno);
  
        renderrequest.getPortletSession().setAttribute(imputacionBean,imputacionSalarioAlumno);
  }
  
  public final void setJustificanteAsociarCostesSalarioAlumno(ImputacionBean imputacionSalario) {
      this.imputacionBean = imputacionSalario;
  }
  </code></pre>
  
  <p>The first time the bean that handles spring is object empty. My question is: how I can set the session bean that handles Spring from the first controller? so when generating the request this bean contains data.</p>
  
  <p>I need change the bean that handles Spring to generate the new request whit this data.</p>
  
  <p>Thanks for the help. If there is something you do not understand I will try to explain it better.</p>