Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sessions

 
Nick Delauney
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, I have some code I was working on for friend. For some reason the session objects work on my machine but not on his. Can anyone tell me why this could happen? Do you have to declare a session object before you use it ? or is it automatic ?
Thanks,
 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
specify the scope at the top of the page
 
Jason Taylor
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must explicitly define a session object, another thing if you are using jsp and you want to retrieve the object you placed in the session you must typecast the object,that was placed in the session, back to what it originally was.
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sessions are automatically created by the WebServer, you don't need to explicitly create one. (Which WebServer are you using ?)
If you are having problems with sessions it could be that a new session is being created for each Http Request. You can check this by retreiving the id of the current session from the request:
request.getSession().getId();
If everything is working correctly, the same Session Id should be be returned for each request from a specific client (until they shut their browser). If not then it would appear that a different session is being created for each request. This could be due to a number of issues e.g. the original session could have timed out due to having too small a session lifetime configured on the server or the web container cannot locate the session id from the incoming request (This is typically stored in a cookie or request parameter with a name of jsessionid).
I suggest that you do a bit of detective work and see if you can read the session id from the incoming request.
HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic