code: void exportToVariable(Object result) throws JspTagException {
          /*
          * Store the result, letting an IllegalArgumentException
          * propagate back if the scope is invalid (e.g., if an attempt
          * is made to store something in the session without any
          * HttpSession existing).
          */
          int scopeValue = Util.getScope(scope);
          ELContext myELContext = pageContext.getELContext();
          VariableMapper vm = myELContext.getVariableMapper();
          if (result != null) {
              // if the result is a ValueExpression we just export to the mapper
              if (result instanceof ValueExpression) {
                  if (scopeValue != PageContext.PAGE_SCOPE) {
                      throw new JspTagException(Resources.getMessage("SET_BAD_DEFERRED_SCOPE", scope));
                  }
                  vm.setVariable(var, (ValueExpression) result);
              } else {
                  // make sure to remove it from the VariableMapper if we will be setting into page scope
                  if (scopeValue == PageContext.PAGE_SCOPE && vm.resolveVariable(var) != null) {
                      vm.setVariable(var, null);
                  }
                  pageContext.setAttribute(var, result, scopeValue);
              }
          } else {
              //make sure to remove it from the Var mapper
              if (vm.resolveVariable(var) != null) {
                  vm.setVariable(var, null);
              }
              if (scope != null) {
                  pageContext.removeAttribute(var, Util.getScope(scope));
              } else {
                  pageContext.removeAttribute(var);
              }
          }
      }
docs: Export the result into a scoped variable.
  
  @param result the value to export
  @throws JspTagException if there was a problem exporting the result