Session handling across the nodes and web server | Community
Skip to main content
hitesh_m
Level 3
April 8, 2016

Session handling across the nodes and web server

  • April 8, 2016
  • 2 replies
  • 3489 views

Hi experts, 

 

I am working in an AEM app which does following -

 

  1. User submits the data through AEM forms
  2. We collect the data in AEM form action jsp and make a string 
  3. We store string in a session (HTTP session i.e. session.setAttribute )
  4. AEM redirects user to a thank you page
  5. We have a “Call to action” on thank you page
  6. On this call to action, we hit a backend JSP say”createfile.jsp” that reads the string from session variable and create a text file to download (session.getAttribute)

 

This works in single nodes (like author, publish etc), but when I am dealing with the web server it doesn’t. I am not able to collect the session data.  I have 2 author, 2 pub nodes and 1 web server.

 

Here is the form action script

submiForm.jsp

<%

String str=request.getParameter("bnfname4");

request.getSession().setAttribute("data", str);

%>

 

 

Here is the createfile.jsp

<%

String txt=(String)request.getSession().getAttribute("data");

 

%>

 

Any idea??

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Lokesh_Shivalingaiah
Level 10
April 8, 2016

Have you set up sticky connections ??

If you are managing sessions between 2 pub instance with 1 web server, you need to configure the sticky connection in the dispatcher

Tuhin_Ghosh
Level 8
April 14, 2016

You definitely have to use sticky connection to address this issue, as Loki said. I guess from AEM 6.2 we dont have to use sticky session anymore with these kind of scenarios. Am I correct @bsloki.

Yogesh_Upadhyay
Level 6
April 14, 2016

Hello Tuhin,

Using server side session is not recommended in AEM, you can not cache pages and use proper load balancing if server side session is enabled. Would recommend to save this data to either client context or cookie or query param or Use some kind of session storage (couch base or something). Long run it will help you.

Yogesh 

Tuhin_Ghosh
Level 8
April 14, 2016

Yogesh Upadhyay wrote...

Hello Tuhin,

Using server side session is not recommended in AEM, you can not cache pages and use proper load balancing if server side session is enabled. Would recommend to save this data to either client context or cookie or query param or Use some kind of session storage (couch base or something). Long run it will help you.

Yogesh 

 

Hi Yogesh,

I totally agree with what you are saying. But if I am not wrong we are not form pages are not cached, right? And if the data is not heavy would sticky connection be creating so much performance overhead. It would be only for the forms pages nevertheless. The rest of the pages would be cached. Please correct me if I am wrong.

Thanks

Tuhin