Moved function to retrieve the environment to RichServletContext.