public static void afterRoot(
      FacesContext context, HttpServletRequest req, HttpServletResponse res) {
    HttpSession session = ((HttpServletRequest) req).getSession(false);

    if (session != null)
      session.setAttribute(ViewHandler.CHARACTER_ENCODING_KEY, res.getCharacterEncoding());
  }
예제 #2
0
  /**
   * Evaluate the expr as an object.
   *
   * @param env the page context
   */
  @Override
  public Object getValue(ELContext env) throws ELException {
    if (!(env instanceof ServletELContext))
      return env.getELResolver().getValue(env, null, "session");

    env.setPropertyResolved(true);

    ServletELContext servletEnv = (ServletELContext) env;

    HttpServletRequest req = servletEnv.getRequest();

    HttpSession session = req.getSession(false);

    if (session != null) return session.getAttribute(_field);
    else return null;
  }