Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Killing HttpSession  RSS feed

 
Ankita Jha
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
I have a web application where in depending on the year selection my application will get connected to different schemas,
There problem is :

When i login with year as 2008-2009 i get a list of banks For e.g {ICIC,HDFC}

Then if i log out, and login with year 2009-2010 i shld get different list of bank ie {AXIS,SICOM}

but i get ICICI and HDFC.

Pasting the Code for Logout .I guesss.. session is not getting killed.Is there any other way for Killing HttpSession .



I specify my database connection in my Context.xml.

Please treat this as urgent.

Any help will be appreciated.

 
Dawn Charangat
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why dont you try session.removeAttribute(attribute to be removed) before invalidating the session ? This is definitely not the optimum solution... but something which can be used as a stopgap solution until you find the right one.

Dawn
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session.invalidate() is quite enough.
No need to remove the attribute from session.

And regarding to your problem:

Could you let us know how you are calling the different schema conditionally.
I believe there is the problem.

 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What evidence leads you to believe that the session is not inactivated?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send a redirect after HttpSession#invalidate(). The session is only physically gone AFTER completing the response (simply because the response cookie have still to be sent yet).
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send a redirect after HttpSession#invalidate(). The session is only physically gone AFTER completing the response (simply because the response cookie have still to be sent yet).


As I understand it, when a call to invalidate completes, ALL references to contained objects have been removed and the session is marked as invalid. Any request containing the old session ID will not recover the invalid session, so I dont know what "physically gone" means in this context. If anybody has example code that contradicts this view I would love to see it.

My wild guess is that an instance variable is being used incorrectly.

Bill
 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul's advise. a HttpSession session=req.getSession(false) will give you a clue if there is an instance variable being used incorrectly as stated by William.
 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why don't you try using the session object after invalidating it, if you get an exception you know your code is fine and the problem is related to logic. In rare cases sometimes just restarting the server and the IDE solves issues.
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

You said the database connection with the different schema is dependent on the user YEAR selection.

Are you storing the year selection in session.

If this is the case:
First try to get the values from the user selection().
If it gives null then try to get it from the session.








 
Ankita Jha
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys,
got it working...thnks...problem was with DataSource...

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!