0

Our Action class implements SessionAware, on page load for the first time, we are setting some data into the session (session map which we get by implementing SessionAware). we have a functionality which makes page re load, in this case session data is becoming null, when i further observed, the jsession id is being changed, i believe this is causing the issue, could you please share your thoughts on why this happens, how do i enforce my struts2 application to use the existing session.

This issue doesn't happen in my local environment, this is observed only when deployed on QA server (tomcat server deployed on unix environment)

Our application uses tomcat server.

Could any settings in tomcat can lead to this? or is this something to do with application code?

Pramod CA
  • 47
  • 3
  • 11
  • What do you mean by page reload? Could you show code. – Aleksandr M Oct 10 '12 at 08:24
  • Are you setting the session in jsp using `` tag?Make sure you set the session values in action classe. Another solution is to check for existing session values for null before setting it – Anupam Oct 10 '12 at 08:38
  • @ Aleksandr M , say i am in one.jsp, after a particular request, details are fetched and populated and one.jsp is rendered again to show the latest data, is this clear? – Pramod CA Oct 10 '12 at 09:22
  • @anu data is set in Action class and not in jsp. – Pramod CA Oct 10 '12 at 09:23
  • Are you using default struts2 interceptor stack? – Aleksandr M Oct 10 '12 at 10:15
  • In that case in the action class, before you set the session value, check if it is null. If not null then dont set any value. Although this is a bad design, the session usually must be set in login class and should not be called again. – Anupam Oct 10 '12 at 10:20
  • @AleksandrM : yes, we do use default struts2 interceptor stack – Pramod CA Oct 10 '12 at 12:01
  • @anu : Its not that session itself is null, there is a session with different jsessionid(i believe its a new session), when page is re loaded all the values that were loaded during first time page load will not be there, which i need. – Pramod CA Oct 10 '12 at 12:10
  • Is it a clustered environment? This is almost certainly a container issue. – Dave Newton Oct 10 '12 at 13:56
  • @DaveNewton : we checked that also, its not in a clustered environment, its just a single instance of server set up in unix environment – Pramod CA Oct 10 '12 at 14:42

1 Answers1

0

I had the same problem when trying to move my local application to our server. Try if this can help you:

Struts2: Session Problem (after reverse proxy)

Community
  • 1
  • 1
Akku
  • 4,373
  • 4
  • 48
  • 67