title: SlingModels: Can I inject the SlingHttpServletRequest when adapting from Resource?
body: <p>I am new to SlingModels and the annotations aren't very clear yet. I am currently trying to transform some basic foundation components from AEM 6.2 to using SlingModels instead. </p>
  
  <p>For the image component the foundation JSP uses the SlingHttpServletRequest to set the ImageDoctype. So I tried the following:</p>
  
  <pre><code>@Model(adaptables = {Resource.class})
  public class ImageModel {
      @SlingObject
      private SlingHttpServletRequest request;
  
      @SlingObject
      private Resource resource;
  }
  </code></pre>
  
  <p>But with this the <code>request</code> is null. So I switched to using:</p>
  
  <pre><code>@Model(adaptables = {SlingHttpServletRequest.class})
  </code></pre>
  
  <p>Which works now for <code>reuqest</code> and <code>resource</code></p>
  
  <p>JSP Code:</p>
  
  <pre><code>&lt;sling:adaptTo adaptable="${slingRequest}" adaptTo="models.ImageModel" var="m"/&gt;
  </code></pre>
  
  <p>Is this the right way to do it or is there a way to adapt from the <code>resource</code> ans still be able to inject the <code>request</code>?</p>