code: public void actionChtype() throws JspException {
  
          int plainId;
          try {
              plainId = OpenCms.getResourceManager().getResourceType(
                  CmsResourceTypePlain.getStaticTypeName()).getTypeId();
          } catch (CmsLoaderException e) {
              // this should really never happen
              plainId = CmsResourceTypePlain.getStaticTypeId();
          }
          try {
              int newType = plainId;
              try {
                  // get new resource type id from request
                  newType = Integer.parseInt(getParamSelectedType());
              } catch (NumberFormatException nf) {
                  throw new CmsException(Messages.get().container(Messages.ERR_GET_RESTYPE_1, getParamSelectedType()));
              }
              // check the resource lock state
              checkLock(getParamResource());
              // change the resource type
              getCms().chtype(getParamResource(), newType);
              // close the dialog window
              actionCloseDialog();
          } catch (Throwable e) {
              // error changing resource type, show error dialog
              includeErrorpage(this, e);
          }
      }
docs: Uploads the specified file and replaces the VFS file.<p>
  
  @throws JspException if inclusion of error dialog fails