/**
   * @param context the Servlet context.
   * @deprecated Now handled in TdsContext.init().
   */
  public static void initContext(ServletContext context) {
    //    setContextPath(context);
    if (contextPath == null) {
      // Servlet 2.5 allows the following.
      // contextPath = servletContext.getContextPath();
      String tmpContextPath =
          context.getInitParameter("ContextPath"); // cannot be overridden in the ThreddsConfig file
      if (tmpContextPath == null) tmpContextPath = "thredds";
      contextPath = "/" + tmpContextPath;
    }
    //    setRootPath(context);
    if (rootPath == null) {
      rootPath = context.getRealPath("/");
      rootPath = rootPath.replace('\\', '/');
    }

    //    setContentPath();
    if (contentPath == null) {
      String tmpContentPath = "../../content" + getContextPath() + "/";
      File cf = new File(getRootPath(), tmpContentPath);
      try {
        contentPath = cf.getCanonicalPath() + "/";
        contentPath = contentPath.replace('\\', '/');
      } catch (IOException e) {
        throw new RuntimeException(e.getMessage());
      }
    }

    //    initDebugging(context);
    initDebugging(context);
  }
  protected ModelAndView onSubmit(
      HttpServletRequest request,
      HttpServletResponse response,
      Object command,
      BindException errors)
      throws ServletException, IOException, Exception {

    // cast the bean.  i only care about the File property in this controller
    UploadMasterBean bean = (UploadMasterBean) command;

    MultipartFile multipartFile = bean.getFile();
    if (multipartFile != null) {
      System.out.println("name " + multipartFile.getOriginalFilename());
      System.out.println("size " + multipartFile.getSize());

      File fileOut = new File(FileUtils.createTempDir(), multipartFile.getOriginalFilename());

      System.out.println("File written to " + fileOut.getCanonicalPath());

      multipartFile.transferTo(fileOut);

      String path = fileOut.getCanonicalPath();
      String extension = FileUtils.getFileExtension(path);

      if (("png".equals(extension))
          || ("PNG".equals(extension))
          || ("jpg".equals(extension))
          || ("JPG".equals(extension))
          || ("gif".equals(extension))
          || ("GIF".equals(extension))) {

        // TODO check and warn if this isn't transparent.  Alpha?

        catalogManager.addWatermark(fileOut);

      } else {
        System.out.println(path + " not imported.");
      }
    }

    // return new ModelAndView("uploadResults", "model", model);
    return new ModelAndView("redirect:listWatermarks.html");
  }