code: public static <T> AttributeKey<T> appScoped() {
          return new AttributeKey<T>() {
              public T get(HttpServletRequest req) {
                  return (T) getContext(req).getAttribute(name);
              }
  
              public void set(HttpServletRequest req, T value) {
                  getContext(req).setAttribute(name, value);
              }
  
              public void remove(HttpServletRequest req) {
                  getContext(req).removeAttribute(name);
              }
  
              private ServletContext getContext(HttpServletRequest req) {
                  return ((StaplerRequest)req).getServletContext();
              }
          };
      }
docs: Creates a new {@link ServletContext}-scoped {@link AttributeKey}.