The Spring controller contains following codes public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
Collection channels = channelDAO.getHomeUris(); ModelAndView view = new ModelAndView("index","channelDAO",channelDAO); view.addObject("message",greeting); view.addObject("homeuris",channels); return view; } In Velocity template, When I am trying to use channelDAO or message or homeuris collection it returns following exception Velocity code: #set($greeting = $req.getAttribute("message")) $greeting #set($channelDAO = $req.getAttribute("channelDAO") ) #set($channels = $req.getAttribute("homeuris")) #foreach ( $item in $channels) On this iteration, \$item refers to the value $item. #end Exception: (app.VelocityEngine 43 ) RHS of #set statement is null. Contex t will not be modified. /html/index.vm [line 90, column 17] (app.VelocityEngine 46 ) org.apache.velocity.runtime.exception .ReferenceException: reference : template = /html/index.vm [line 91,column 17] : $greeting is not a valid reference. (app.VelocityEngine 43 ) RHS of #set statement is null. Contex t will not be modified. /html/index.vm [line 92, column 17] I am sure messageDAO, or homeuris or homeuris has been initialized before adding to view object. Any suggestion? regards, Ranjan