• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

URGENT DOUBT 3--- SESSION HANDLING

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From Vel's Notes:
1.2.given a scenario, state whether a session object will be invalidated
1.2.1.ideally, a session would be invalidated as soon as the user closed his browser, browsed to a different site, or stepped away from his desk. Unfortunately, there’s no way for a server to detect any of these events.
Can someone please explain me 1.2.1.
I am confused.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sanjay sawant:
From Vel's Notes:
1.2.given a scenario, state whether a session object will be invalidated
1.2.1.ideally, a session would be invalidated as soon as the user closed his browser, browsed to a different site, or stepped away from his desk. Unfortunately, there’s no way for a server to detect any of these events.
Can someone please explain me 1.2.1.
I am confused.


as soon as the user closed his browser-->
this situtaion can be detected in IE with the help of javascript. so we can easily invalidate the session. don't know abt other browsers.
browsed to a different site---> this situation can be detected in IE and NN both so we can easily invalidate the session if we want.don't know abt other browsers.
stepped away from his desk---> :roll:
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gautam
Alright we can capture all those browser-window event with javascript on client-side , but in this case these events are interest of server-only , coz that is where actual session is being maintained.
is there a way you can communicate these events to server ? one may think yes , with javascript send info over HTTP but for that u will need to open another window ! or acces other URL etc etc .
And then these are just few of the 'ideal' conditions , you cant build 'trap' for all such things occuring on the client side
So much better way is to use 'timeouts' at server-side , which is what a web-container like tomcat/resin does
 
gautam shah
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gagan Indus:
Gautam
Alright we can capture all those browser-window event with javascript on client-side , but in this case these events are interest of server-only , coz that is where actual session is being maintained.
is there a way you can communicate these events to server ? one may think yes , with javascript send info over HTTP but for that u will need to open another window ! or acces other URL etc etc .
And then these are just few of the 'ideal' conditions , you cant build 'trap' for all such things occuring on the client side
So much better way is to use 'timeouts' at server-side , which is what a web-container like tomcat/resin does


Hi Gagan
what i had said abt both situation is a perfectly working solution implemented by me . offcourse i have to follow a url in that case but didn't need to open a additional browser window .according to me every http request recieved by server is an "event" after recieving of that, server starts to perform an action on basis of that. ya a good understanding of http session is required there.
in this case i have used javascript to "dispatchEvent".
using timeouts is entirely different thing then that.
and above all client requirement satisfication is must to get the salary on 7th.

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't rely on a Javascript solution - suppose the user's connection gets dropped.
Bill
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gaurav
I have no doubt that the solution you recommended/implemented is working , i havent even raised a question about that .
Alright if we may please we can always write javascript and all to do so
( a javascript which ll capture the browser closing window event , it will invoke a servlet at the server which ll call the session.invalidate() , this is all it takes )
But then you seem to be missing a point here ,
The discussion above is about the automatic session-management facilites provided by all web-containers implemented according to JSR specs and NOT the hand-coded session-management
If you may choose you can even skip all the session-management facilties already built-into the servlet framework , and code your own from scratch , or extend them the way you like .
The web-container manages session primarly using cookies/url-rewriting ( it inserts the jsessionid for us right ? ) , but it do NOT provide any middle-tier callbacks on :
-closing of client window
-client moving to another website
-etc etc
Instead the web-containers use timeouts.
And ,these are just few of the conditions , you cant code callbacks for all such conditions even if you choose to do so. Lets says the clients connections breaks down without warning , surely we cant do any sort of 'callback' in this case. Here 'timeouts' shine.

Never re-invent the wheel ! especailly if you like to get your salary before 7th
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh i meant Gautam , NOT Gaurav .. :roll:
and yes William yer right we absolutely cant reply on javascript ( it isnt even supported as-is by all client )
 
gautam shah
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gagan Indus:
Oh i meant Gautam , NOT Gaurav .. :roll:
and yes William yer right we absolutely cant reply on javascript ( it isnt even supported as-is by all client )


both of u r right. but some times it could be happened that ur server may wish to not to invalidate the session after specified time out.
then what only we can do is to just poke our hands in side the server and after searching our session
we should pray in front of that
" Ki Bhai mere ab to logout ho ja"
and till this time i am getting my salary on or before 7th just because of this spirit i think.
"Aur Aage bhagwan malik"
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL Gautum....
i feed my web-server well , so it do not play games like those with me ..
Translation Side-bar
" Ki Bhai mere ab to logout ho ja"
-->
Hey man please do logout now
"Aur Aage bhagwan malik"
-->
Future is in God's hands
 
reply
    Bookmark Topic Watch Topic
  • New Topic