Example #1
0
  /**
   * Prepare a request, including setting the encoding and locale.
   *
   * @param request The request
   * @param response The response
   */
  public void prepare(HttpServletRequest request, HttpServletResponse response) {
    String encoding = null;
    if (defaultEncoding != null) {
      encoding = defaultEncoding;
    }
    // check for Ajax request to use UTF-8 encoding strictly
    // http://www.w3.org/TR/XMLHttpRequest/#the-send-method
    if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
      encoding = "UTF-8";
    }

    Locale locale = null;
    if (defaultLocale != null) {
      locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
    }

    if (encoding != null) {
      applyEncoding(request, encoding);
    }

    if (locale != null) {
      response.setLocale(locale);
    }

    if (paramsWorkaroundEnabled) {
      request.getParameter(
          "foo"); // simply read any parameter (existing or not) to "prime" the request
    }
  }
Example #2
0
  /**
   * Prepare a request, including setting the encoding and locale.
   *
   * @param request The request
   * @param response The response
   */
  public void prepare(HttpServletRequest request, HttpServletResponse response) {
    String encoding = null;
    if (defaultEncoding != null) {
      encoding = defaultEncoding;
    }

    Locale locale = null;
    if (defaultLocale != null) {
      locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
    }

    if (encoding != null) {
      try {
        request.setCharacterEncoding(encoding);
      } catch (Exception e) {
        LOG.error("Error setting character encoding to '" + encoding + "' - ignoring.", e);
      }
    }

    if (locale != null) {
      response.setLocale(locale);
    }

    if (paramsWorkaroundEnabled) {
      request.getParameter(
          "foo"); // simply read any parameter (existing or not) to "prime" the request
    }
  }
 @Override
 public void setLocale(Locale locale) {
   response.setLocale(locale);
 }
 public synchronized void setLocale(Locale arg0) {
   actualResponse.setLocale(arg0);
 }
Example #5
0
 public void setLocale(Locale loc) {
   rawResponse.setLocale(loc);
 }
 public void setOutput(HttpServletResponse res) {
   res.setContentType("text/html; charset=" + outputEncoding_);
   res.setLocale(locale_);
 }