code: public static String removeFileExtension(CmsObject cms, String resourcename, String extension) {
  
          if (resourcename.equals("")) {
              resourcename = "/";
          }
  
          // get the filename without the path
          String name = CmsResource.getName(resourcename);
  
          String[] tokens = name.split("\\.");
          String suffix = null;
  
          // check if there is more than one extension
          if (tokens.length > 2) {
  
              // check if last extension is "jsp"
              if (extension.equalsIgnoreCase(tokens[tokens.length - 1])) {
  
                  suffix = "." + extension;
  
                  // check if there is another extension with a numeric index
                  if (tokens.length > 3) {
  
                      try {
                          int index = Integer.valueOf(tokens[tokens.length - 2]).intValue();
  
                          suffix = "." + index + suffix;
                      } catch (NumberFormatException ex) {
                          // noop
                      }
                  }
              }
          } else if (tokens.length == 2) {
  
              // there is only one extension!!
              // only remove the last extension, if the resource without the extension exists
              // and the extension fits
              if ((cms.existsResource(CmsResource.getFolderPath(resourcename) + tokens[0]))
                  && (extension.equals(tokens[1]))) {
                  suffix = "." + tokens[1];
              }
          }
  
          if (suffix != null) {
  
              String path = resourcename.substring(0, resourcename.length() - suffix.length());
              return path;
          }
  
          return resourcename;
      }
docs: Removes an added file extension from the resource name.<p>
  
  <ul>
  <li>If there is only one extension, nothing will be removed.</li>
  <li>If there are two extensions, the last one will be removed.</li>
  <li>If there are more than two extensions the last one will be removed and
  if then the last extension is a number, the extension with the number
  will be removed too.</li>
  </ul>
  
  @see #addFileExtension(CmsObject, String, String)
  
  @param cms the initialized CmsObject
  @param resourcename the resource name to remove the file extension from
  @param extension the extension to remove
  
  @return the resource name without the removed file extension