Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Accessing to the currently logged in user's Session in an HttpServlet

Avatar

Level 7

Hi,

If I want to implement a servlet that doesn't necessarily map to a resource, is it possible to extend HttpServlet, rather than, for example, SlingAllMethodsServlet, but still access the javax.jcr.Session for the currently logged in user?

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Employee

Yes, although I'm not sure why you would want to do that. If you just have a regular HttpServlet registered with Sling, you can get the current ResourceResolver by doing:

ResourceResolver resolver = (ResourceResolver) request.getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_RESOLVER); Session session = resolver.adaptTo(Session.class)

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

Yes, although I'm not sure why you would want to do that. If you just have a regular HttpServlet registered with Sling, you can get the current ResourceResolver by doing:

ResourceResolver resolver = (ResourceResolver) request.getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_RESOLVER); Session session = resolver.adaptTo(Session.class)