what SlingHttpServletRequest exactly is we can get resource from request how we are getting resource from request?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Keerthi0555,
AEM has been build using multiple layers and technologies. One of the key framework that is used as part of AEM architecture is Apache Sling which is RESTful web-applications based framework.
SlingHttpServletRequest is a Apache Sling extension of HttpServletRequest java class. The extension provides some additional methods that are specific for Apache Sling framework e.g. getResource(), getResourceResolver() etc. Please explore below documentation for all the details:
In terms of getting resource from SlingHttpServletRequest object it can be done via getResource() method or using adaptTo. The main difference is that getResource() is null safe, and getting resource via adaptTo can return null so your code should handle this.
SlingHttpServletRequest request;
// getting resource via adaptTo
Resource resource = request.adaptTo(Resource.class);
// getting resourec via getResource
Resource resource = request.getResource();
Hi @Keerthi0555,
AEM has been build using multiple layers and technologies. One of the key framework that is used as part of AEM architecture is Apache Sling which is RESTful web-applications based framework.
SlingHttpServletRequest is a Apache Sling extension of HttpServletRequest java class. The extension provides some additional methods that are specific for Apache Sling framework e.g. getResource(), getResourceResolver() etc. Please explore below documentation for all the details:
In terms of getting resource from SlingHttpServletRequest object it can be done via getResource() method or using adaptTo. The main difference is that getResource() is null safe, and getting resource via adaptTo can return null so your code should handle this.
SlingHttpServletRequest request;
// getting resource via adaptTo
Resource resource = request.adaptTo(Resource.class);
// getting resourec via getResource
Resource resource = request.getResource();