code: @Restricted(DoNotUse.class)
      public static String getFrom() {
          String from = null, returnValue = null;
          final StaplerRequest request = Stapler.getCurrentRequest();
  
          // Try to obtain a return point either from the Session
          // or from the QueryParameter in this order
          if (request != null
                  && request.getSession(false) != null) {
              from = (String) request.getSession().getAttribute("from");
          } else if (request != null) {
              from = request.getParameter("from");
          }
  
          // If entry point was not found, try to deduce it from the request URI
          // except pages related to login process
          if (from == null
                  && request != null
                  && request.getRequestURI() != null
                  && !request.getRequestURI().equals("/loginError")
                  && !request.getRequestURI().equals("/login")) {
  
                  from = request.getRequestURI();
          }
  
          // If deduced entry point isn't deduced yet or the content is a blank value
          // use the root web point "/" as a fallback
          from = StringUtils.defaultIfBlank(from, "/").trim();
          
          // Encode the return value
          try {
              returnValue = java.net.URLEncoder.encode(from, "UTF-8");
          } catch (UnsupportedEncodingException e) { }
  
          // Return encoded value or at least "/" in the case exception occurred during encode()
          // or if the encoded content is blank value
          return StringUtils.isBlank(returnValue) ? "/" : returnValue;
      }
docs: Perform a calculation where we should go back after successful login
  
  @return Encoded URI where we should go back after successful login
  or "/" if no way back or an issue occurred
  
  @since 2.4