title: How to access Session or Request object in Velocity Template
body: <p>I am trying to access HttpServletRequest in some velocity template but never succeed. 
  I have already tried following flavor of syntax </p>
  
  <p>Current URL: $req.get("attributes").get("CURRENT_URL"))
  Result   >  Current URL: $req.get("attributes").get("CURRENT_URL"))</p>
  
  <p>Current URL: $request.get("attributes").get("CURRENT_URL"))
  Result   >  Current URL: $request.get("attributes").get("CURRENT_URL"))</p>
  
  <p>Current URL: $request.get("attributes").get("CURRENT_URL"))
  Result   >  Current URL: $request.get("attributes").get("CURRENT_URL"))</p>
  
  <p>Current URL: ${request.get("attributes").get("CURRENT_URL"))}
  Result   >  Current URL: ${request.get("attributes").get("CURRENT_URL"))}</p>
  
  <p>Note : Web.xml looks like</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;!-- Processes application requests --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;!-- Define Velocity template compiler --&gt;
  &lt;servlet&gt;
    &lt;servlet-name&gt;velocity&lt;/servlet-name&gt;
    &lt;servlet-class&gt;
      org.apache.velocity.tools.view.servlet.VelocityViewServlet
    &lt;/servlet-class&gt;
  
    &lt;!-- 
     Unless you plan to put your toolbox.xml and velocity.properties
     under different folders or give them different names, then these
     two init-params are unnecessary as of VelocityTools 1.3.  The
     VelocityViewServlet will automatically look for these files in
     the following locations.
   --&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;org.apache.velocity.toolbox&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/toolbox.xml&lt;/param-value&gt;
    &lt;/init-param&gt;
  
    &lt;init-param&gt;
      &lt;param-name&gt;org.apache.velocity.properties&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/velocity.properties&lt;/param-value&gt;
    &lt;/init-param&gt;
  &lt;/servlet&gt;
  
  &lt;!-- Map *.vm files to Velocity --&gt;
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;velocity&lt;/servlet-name&gt;
    &lt;url-pattern&gt;*.vm&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>