Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

how to get uesr details from client context in server side

Avatar

Level 1

Hi,

I would like know how to get the user from client context in my java service.

  1. Is there a way I could pass CQ_Analytics.ProfileDataMgr.getProperty('authorizableId', true) to my java service class. 
  2. or get the client context user details in my Java Service class.

Please let me know if you are looking for more details.

 

Thanks

Nani

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

That's quite simple, as it is teh user, which is executing the request; so somehting like

request.getUserPrincipal()

from the Java servlet API should do the trick. But be aware: The clientside code is always executed in the browser; but when all the responses the client browser made to the server, are actually delivered from a cache, your serverside code is never executed. So if you want to cache your pages, you should not rely on your serverside code.

kind regards,
Jörg

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

That's quite simple, as it is teh user, which is executing the request; so somehting like

request.getUserPrincipal()

from the Java servlet API should do the trick. But be aware: The clientside code is always executed in the browser; but when all the responses the client browser made to the server, are actually delivered from a cache, your serverside code is never executed. So if you want to cache your pages, you should not rely on your serverside code.

kind regards,
Jörg