public static String getFooter(String context) {
    try {
      FileReader fileReader =
          new FileReader(findResourceOnFileSystem("servletResponseTemplate.htm"));
      BufferedReader buffread = new BufferedReader(fileReader);
      String templateFile = "", line;
      StringBuffer SBreader = new StringBuffer();
      while ((line = buffread.readLine()) != null) {
        SBreader.append(line).append("\n");
      }
      fileReader.close();
      buffread.close();
      templateFile = SBreader.toString();
      templateFile =
          templateFile.replaceAll(
              "BOTTOMGRAPHIC", CommonConfiguration.getURLToFooterGraphic(context));

      int end_header = templateFile.indexOf("INSERT_HERE");
      return (templateFile.substring(end_header + 11));
    } catch (Exception e) {
      // out.println("I couldn't find the template file to read from.");
      e.printStackTrace();
      String error =
          "An error occurred while attempting to read from an HTML template file. This probably will not affect the success of the operation you were trying to perform.</p></body></html>";
      return error;
    }
  }
  // Loads a String of text from a specified file.
  // This is generally used to load an email template for automated emailing
  public static String getText(String fileName) {
    try {
      StringBuffer SBreader = new StringBuffer();
      String line;
      FileReader fileReader = new FileReader(findResourceOnFileSystem(fileName));

      BufferedReader buffread = new BufferedReader(fileReader);
      while ((line = buffread.readLine()) != null) {
        SBreader.append(line + "\n");
      }
      line = SBreader.toString();
      fileReader.close();
      buffread.close();
      return line;
    } catch (Exception e) {
      e.printStackTrace();
      return "";
    }
  }
  public static String getHeader(HttpServletRequest request) {
    try {
      FileReader fileReader =
          new FileReader(findResourceOnFileSystem("servletResponseTemplate.htm"));
      BufferedReader buffread = new BufferedReader(fileReader);
      String templateFile = "", line;
      StringBuffer SBreader = new StringBuffer();
      while ((line = buffread.readLine()) != null) {
        SBreader.append(line).append("\n");
      }
      fileReader.close();
      buffread.close();
      templateFile = SBreader.toString();

      String context = getContext(request);

      // process the CSS string
      templateFile =
          templateFile.replaceAll(
              "CSSURL", CommonConfiguration.getCSSURLLocation(request, context));

      // set the top header graphic
      templateFile =
          templateFile.replaceAll(
              "TOPGRAPHIC", CommonConfiguration.getURLToMastheadGraphic(context));

      int end_header = templateFile.indexOf("INSERT_HERE");
      return (templateFile.substring(0, end_header));
    } catch (Exception e) {
      // out.println("I couldn't find the template file to read from.");
      e.printStackTrace();
      String error =
          "<html><body><p>An error occurred while attempting to read from the template file servletResponseTemplate.htm. This probably will not affect the success of the operation you were trying to perform.";
      return error;
    }
  }