title: Getting http-session from a child thread?
body: <p>I'm using spring framework and here's the piece of code I'm using to retrieve the <code>HttpSession</code> object:</p>
  
  <pre><code>ServletRequestAttributes attr;
  try {
      attr = (ServletRequestAttributes) RequestContextHolder
              .currentRequestAttributes();
  } catch (Exception e) { }
  HttpSession session = attr.getRequest().getSession(false);
  </code></pre>
  
  <p>The thing is <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/request/RequestContextHolder.html" rel="nofollow noreferrer">RequestContextHolder</a> </p>
  
  <blockquote>
    <p>Holder class to expose the web request in the form of a <strong><em>thread-bound</em></strong>
    RequestAttributes object.</p>
  </blockquote>
  
  <p>therefore it won't be seen outside of the thread created by the container for handling the request. Is there a way to retrieve the session in some child thread?</p>