title: When we should use scala.util.DynamicVariable?
body: <p>When I read the source of scalatra, I found there are some code like:</p>
  
  <pre><code>protected val _response   = new DynamicVariable[HttpServletResponse](null)
  protected val _request    = new DynamicVariable[HttpServletRequest](null)
  </code></pre>
  
  <p>There is an interesting class named <code>DynamicVariable</code>. I've looked at the doc of this class, but I don't know when and why we should use it? It has a <code>withValue()</code> which is usually be used.</p>
  
  <p>If we don't use it, then what code we should use instead, to solve the problem it solved?</p>
  
  <p>(I'm new to scala, if you can provide some code, that will be great)</p>