• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Session Variables lost!

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I've been working on this issue for a couple of days and i cannot come up with a good explanation for it.

Well the issue is this:

I have a url which forwards to a particular page having two particular variables (a & b). These variables are stored using:

request.getSession().setAttribute("a", a);

Then when the user tries to join on the site those variables are retrieved to be used with registration:

request.getSession().getAttribute("a");

The thing is that the attribute is null! The session id in both cases is the same.

The funny thing is that if i try it locally is works. But when i load it onto our servers it doesn't. The only minimal explanation i can get is that the servers are divided and from the time i set the attributes to the time i get the attributes the server changes so maybe the session values are lost there!

Any explanation from your side guys? if so any solutions you can provide me with?

REgards
NF
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It sounds like the servers might be load balance or something.

Look into setting a sticky bit or something (WAS or some other app server configuration) OR there is a way to force all responses from each session to come from the same server in a load balanced environment.

I know our deployment department has set this for our apps. We have 2 prod / 2 DR servers.

Regards
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is "a" Serializable?
 
Nicky Formosa
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thomas..the server is sticky so it shouldn't be a problem.

As regards to it being serializable...well the variable 'a' is a String!

The other thing that i noticed was that it looses the session when moving from http to https. Since the registration is on a https server i cannot change it. When i temporarily changed it to an Non secure server everything worked fine!


Thanks
NF
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicky Formosa:

The other thing that i noticed was that it looses the session when moving from http to https. Since the registration is on a https server i cannot change it. When i temporarily changed it to an Non secure server everything worked fine!




That's normal and by design.
Sessions created under SSL should be separate from non-secure ones.
This helps to prevent session hi-jacking.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic