aspose file tools*
The moose likes Servlets and the fly likes Session Variables lost! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Variables lost!" Watch "Session Variables lost!" New topic
Author

Session Variables lost!

Nicky Formosa
Greenhorn

Joined: Mar 05, 2007
Posts: 14
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
Thomas Mcfarrow
Ranch Hand

Joined: Jul 09, 2001
Posts: 137
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61222
    
  66

Is "a" Serializable?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nicky Formosa
Greenhorn

Joined: Mar 05, 2007
Posts: 14
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
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Variables lost!