code: static void setResponseLocale(PageContext pc, Locale locale) {
          // set response locale
          ServletResponse response = pc.getResponse();
          response.setLocale(locale);
  
          // get response character encoding and store it in session attribute
          if (pc.getSession() != null) {
              try {
                  pc.setAttribute(REQUEST_CHAR_SET, response.getCharacterEncoding(),
                          PageContext.SESSION_SCOPE);
              } catch (IllegalStateException ex) {
              } // invalidated session ignored
          }
      }
docs: /*
  Stores the given locale in the response object of the given page
  context, and stores the locale's associated charset in the
  javax.servlet.jsp.jstl.fmt.request.charset session attribute, which
  may be used by the <requestEncoding> action in a page invoked by a
  form included in the response to set the request charset to the same as
  the response charset (this makes it possible for the container to
  decode the form parameter values properly, since browsers typically
  encode form field values using the response's charset).
  
  @param pageContext the page context whose response object is assigned
  the given locale
  @param locale the response locale