1 Reply Latest reply on Sep 20, 2011 12:42 AM by Jason Porter

    Retrieve session variable in JSF

    Agnes Eugenio Newbie

      Hi everyone!

      I have an old web application developed using traditional JSP. I created a new application using JSF and Seam.

      User logs in to the old application and his credentials (e.g. username) are saved in a session object. I have a link in the old application which when clicked, will redirect user to the new application. If i retrieve his credentials from the session object in my JSF backing bean, the result is always null.

      Does anyone here know how i can retrieve values of session variable in JSF.

      Below is my sample code.

      In my JSP page, i have:


      In my JSF page:

      HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
      String user = (String) session.getAttribute("user");

      But i cant seem to make this work.

      Thank you