File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doubt regarding sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubt regarding sessions" Watch "doubt regarding sessions" New topic

doubt regarding sessions

Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
hi everyone,

i have a small doubt regarding sessions that i would like to clarify with you guys. say that a user closes the browser while on a site. does the servlet give up the session as soon as the user closes his/her browser or does it close the session when the maxInActiveInterval() has reached?

thank you

Dinuka Arseculeratne.

if who i am is what i have, and what i have is lost, then who am i?<br /> <br />SCJP 5.0<br />SCWCD 1.4<br />SCBCD preparing
Senthil Kumar
Ranch Hand

Joined: Mar 13, 2006
Posts: 264
i guess the server has no way of knowing that the browser was closed.So it should be like invalidating the session only after the max interval time has elapsed.

when you really want something, all the universe always conspires in your favour.<br /> <br />SCJP1.5-77%<br />SCWCD-89%
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

The application cannot find out when the user has closed his browser. So the session times out when the interval inactive interval times out.

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
thank you guys for clearing my doubt.

Dinuka Arseculeratne
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
Hey i will give a nice example to clarify more -

Say you went at a shopping mall, filled your shopping cart with things,
suddenly you got a urgent call from home and left for home keeping the cart as it is there.The person at the shopping mall wont have a idea and will not even touch your cart. But after some time, may be at the end of the day he will disassemble your cart.

Similary, if you are into a SESSION on a website, and suddenly close the browser, your session is still maintained. The server/container will not touch it for some time - determined by the setMaxAgeInterval( ) [if its set]. After that interval expires OR after some CONTAINER speecific time expires, the container will INVALIDATE the session

Hope that helps you understand even better

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
I agree. Here's the link:
subject: doubt regarding sessions
It's not a secret anymore!