title: Accessing HttpServletRequest object in a normal Java class from Spring
body: <p>I have a normal Java class in a Spring MVC 3.06 web application. </p>
  
  <p>In this class I would like to inject or get hold of the <code>HttpServletRequest</code> object in a method. </p>
  
  <p>I know I can pass this around, but I was wondering how can I get hold of the request without passing it in to the method. Perhaps using annotations or similar?</p>
  
  <p>Also, what are the "real" concerns with getting hold of the request this way, except some peoples opinions of it being ugly coding. I mean, is it unstable to access it this way?</p>
  
  <p>Preferably non application server dependent way.</p>
  
  <p>I have seen </p>
  
  <pre><code>(HttpServletRequest) RequestContextHolder.getRequestContext().getExternalContext().getNativeRequest() 
  </code></pre>
  
  <p>but this doesn't seem to work for Spring MVC 3.06 . <code>RequestContextHolder</code> doesn't have the method <code>getRequestContext()</code>. </p>