@RequestMapping(method = RequestMethod.GET)
  public String printHello(ModelMap model, HttpServletRequest request) {

    // get the view context from the servlet context
    ViewContext viewContext = (ViewContext) request.getSession().getServletContext().getAttribute(ViewContext.CONTEXT_ATTRIBUTE);

    // get the current user name from the view context
    String userName = viewContext.getUsername();

    // add the greeting message attribute
    model.addAttribute("greeting", "Hello " + (userName == null ? "unknown user" : userName) + "!");

    return "hello";
  }
Controller for the Hello Spring app view.
ambari-views/examples/hello-spring-view/src/main/java/org/apache/ambari/view/hello/HelloController.java