code: protected String getResponseEncoding(FacesContext context, String orig)
      {
          String encoding = orig;
  
          // see if we need to override the encoding
          Map<Object, Object> m = context.getAttributes();
          Map<String, Object> sm = context.getExternalContext().getSessionMap();
  
          // 1. check the request attribute
          if (m.containsKey(PARAM_ENCODING))
          {
              encoding = (String) m.get(PARAM_ENCODING);
              if (encoding != null && log.isLoggable(Level.FINEST))
              {
                  log.finest("Facelet specified alternate encoding '" + encoding + "'");
              }
  
              sm.put(CHARACTER_ENCODING_KEY, encoding);
          }
  
          // 2. get it from request
          if (encoding == null)
          {
              encoding = context.getExternalContext().getRequestCharacterEncoding();
          }
  
          // 3. get it from the session
          if (encoding == null)
          {
              encoding = (String) sm.get(CHARACTER_ENCODING_KEY);
              if (encoding != null && log.isLoggable(Level.FINEST))
              {
                  log.finest("Session specified alternate encoding '" + encoding + "'");
              }
          }
  
          // 4. default it
          if (encoding == null)
          {
              encoding = DEFAULT_CHARACTER_ENCODING;
              if (log.isLoggable(Level.FINEST))
              {
                  log.finest("ResponseWriter created had a null CharacterEncoding, defaulting to " + encoding);
              }
          }
  
          return encoding;
      }
docs: Generate the encoding
  
  @param context
  @param orig
  @return