SlingHttpServletRequest | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
lukasz-m
lukasz-mAccepted solution
New Participant
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();

 

1 reply

lukasz-m
lukasz-mAccepted solution
New Participant
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();

 

Translate