title: How to set ServletContext property for a bean in Spring XML metadata configuration
body: <p>I tried searching here on SO but i couldn't find a solution. I have some XML metadata like the following.</p>
  
  <pre><code>&lt;bean class="javax.servlet.ServletContext" id="servletContext" /&gt;
  
  &lt;bean class="com.abc.ProductController"&gt;
      &lt;property name="servletContext" ref="servletContext"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>With this configuration I am getting an exception saying that <code>"javax.servlet.ServletContext"</code> is an interface and it couldn't create a bean with the id <code>servletContext</code>. The ProductController class is in some jar which I can't modify but I want it as a bean in my application. It has ServletContext property autowired.</p>