code: public static <T> T getRequestAttribute(ServletRequest req, String name, Class<T> cls, Set<GetOpts> opts, T defaultValue)
  	{
  		Object o;
  
  		if(req == null)
  			throw new NullPointerException("req cannot be null");
  		if(name == null)
  			throw new NullPointerException("name cannot be null");
  		if(cls == null)
  			throw new NullPointerException("cls cannot be null");
  		if(opts == null)
  			opts = EMPTY_OPTS;
  		if((o = req.getAttribute(name))==null)
  		{
  			if(opts.contains(GetOpts.THROW_ON_MISSING))
  				throw new IllegalStateException("Request attribute " + name + " is not present.");
  			if(opts.contains(GetOpts.LOG_ON_MISSING))
  				logger.warn("Request attribute " + name + " is not present.");
  			return defaultValue;
  		}
  		if(!cls.isInstance(o))
  		{
  			if(opts.contains(GetOpts.THROW_ON_WRONG_TYPE))
  				throw new IllegalStateException("Request attribute " + name + " was of type " + o.getClass().getName() + " instead of " + cls.getName());
  			if(opts.contains(GetOpts.LOG_ON_MISSING))
  				logger.warn("Request attribute " + name + " was of type " + o.getClass().getName() + " instead of " + cls.getName());
  			return defaultValue;
  		}
  		return cls.cast(o);
  	}
docs: /* getRequestAttribute(...)