title: how to inject webapp resource using relative path in spring
body: <p>I have a bean which im trying to pass a relative path at web application startup.  It works for an absolute path (running tomcat within eclipse) such as (<strong>C:/dev/workspace/project/src/main/webapp/WEB-INF/resource/</strong>) </p>
  
  <p>However when  I try to pass it a relative path such as <strong>WEB-INF/my_resource/</strong> it says cannot find the location <strong>C:/dev/eclipse/WEB-INF/my_resource/</strong> probably because tomcat is running within eclipse.  How can I make this path relative so that it will be always picked up from whatever webcontainer is running it no matter the location of the webapp?</p>
  
  <p>Ive read in place to use the servletconfig.getRelativePath(/) but neither know how to obtain the servlet config from within my bean or even if this is the right thing to do in Spring... Please help</p>
  
  <p>The source code for my bean class and bean configuration xml can be found below</p>
  
  <pre><code>public class SuggestionIndexSearcher extends IndexSearcher {
  
  private String indexSearcherType;
  
  public SuggestionIndexSearcher(String type, String path){
      super(path);
      this.indexSearcherType = type;
  }
  ...
  }
  </code></pre>
  
  <p>The bean is defined in teh beans xml as...</p>
  
  <pre><code>    &lt;bean id="KMSearcherBean" class="com.hp.it.km.search.web.suggestion.SuggestionIndexSearcher"&gt;
        &lt;constructor-arg index="0" value="KMSearcher" /&gt;
        &lt;constructor-arg index="1" value="WEB-INF/resource/keyword" /&gt;
  &lt;/bean&gt;
  </code></pre>