Access session storage in Java | Adobe Higher Education
Skip to main content
Level 2
December 19, 2022
Respondido

Access session storage in Java

  • December 19, 2022
  • 2 respostas
  • 1721 Visualizações

Hi All,

I have items in session storage that I want to use in backend.

I have tried Servlet class with get method but was unable to get the item. 

Can anybody with experience help me out ?

Este tópico foi fechado para respostas.
Melhor resposta por arunpatidar

https://sling.apache.org/apidocs/sling11/org/apache/sling/api/SlingHttpServletRequest.html#getCookie-java.lang.String- 

 

Here is the example

 

Cookie countryCookie = slingRequest.getCookie("myCountryCookie"); if(countryCookie==null) { String cookieValue = countryCookie.getValue(); // rest of the logic }

 

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/DemoCookieFilter.java 

2 Respostas

arunpatidar
Community Advisor
Community Advisor
December 19, 2022

You cannot access browser session storage at server side, only cookies can be retrieve and updated from backed.

Arun Patidar
Level 2
December 19, 2022

.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorResposta
Community Advisor
December 19, 2022

https://sling.apache.org/apidocs/sling11/org/apache/sling/api/SlingHttpServletRequest.html#getCookie-java.lang.String- 

 

Here is the example

 

Cookie countryCookie = slingRequest.getCookie("myCountryCookie"); if(countryCookie==null) { String cookieValue = countryCookie.getValue(); // rest of the logic }

 

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/DemoCookieFilter.java 

Arun Patidar
Mani_kumar_
Community Advisor
Community Advisor
December 19, 2022

Once you get the cookie, map all the countries codes which you want to convert or maintain a Generic list in the AEM with all the mappings and get the values from the list

Please find the reference for using generic lists

https://adobe-consulting-services.github.io/acs-aem-commons/features/generic-lists/index.html

 

Hope this is helpful