SlingHttpServletRequest | Adobe Higher Education
Skip to main content
Ce sujet a été fermé aux réponses.
Meilleure réponse par lukasz-m

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();

 

1 commentaire

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorRéponse
Community Advisor
April 29, 2023

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();