tds/src/main/java/thredds/servlet/ServletUtil.java
public static int setResponseContentLength(HttpServletResponse response, String s) throws UnsupportedEncodingException {
    int length = s.getBytes(response.getCharacterEncoding()).length;
    response.setContentLength(length);
    return length;
  }
public static int setResponseContentLength(HttpServletResponse response, String s) throws UnsupportedEncodingException {
    int length = s.getBytes(response.getCharacterEncoding()).length;
    response.setContentLength(length);
    return length;
  }
Set the proper content length for the string

@param response the HttpServletResponse to act upon
@param s the string that will be returned
@return the number of bytes
@throws UnsupportedEncodingException on bad character encoding