Friday, May 21, 2010

Setting and Getting Attributes from session

//Setting Attribute in session.
String userID="Subin";
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false); session.setAttribute("userId", userID);

//Getting Attribute from the session.
HttpServletRequest hsr = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String userName = (String) hsr.getSession().getAttribute("userId");

JSF Related topics: JCaptcha in JSF, Integrating Richfaces with JSF,Getting client and server sessionId in JSF,PopUp AlertMessagebox for JSF and more.....

No comments:

Post a Comment