title: How to access component properties from a Java Class
body: <p>I am working on a component which requires some properties (that the user sets during run time) for it to work as intended.</p>
  
  <p>Initially, I was simply using a <code>properties.get('foo')</code> to fetch the needed property from my component, but I'm trying to remove all traces of script-let code from my component jsp file.</p>
  
  <p>How do I fetch this property 'foo' (which is set during runtime on my component) within my Java code? I remember reading somewhere that using a ValueMap was the best way, so I tried using this:-</p>
  
  <pre><code>public static Map&lt;String, Object&gt; getResourceProperties(String path,
              SlingHttpServletRequest request) {
          ResourceResolver resourceResolver = request.getResourceResolver();
          Map&lt;String, Object&gt; props= new HashMap&lt;String, Object&gt;();
          Resource resource = resourceResolver.getResource(path);
          if (null != resource) {
              props.putAll(resource.adaptTo(ValueMap.class));
          }
          return props;
      } 
  </code></pre>
  
  <p>and this in my jsp:- <code>&lt;c:set var="refProperties" value="${xyz:getResourceProperties(properties.path,slingRequest)}" /&gt;</code></p>
  
  <p>But this doesn't return the value I want.</p>