| Author |
setMaxInactiveInterval and <session-timeout> question
|
Chrix Wu
Ranch Hand
Joined: Nov 15, 2009
Posts: 121
|
|
are the following four the same ?
|
** SCJP 5.0 84% **
** SCWCD 1.5 76% **
|
 |
Chrix Wu
Ranch Hand
Joined: Nov 15, 2009
Posts: 121
|
|
Found a potential incorrect note in FREDERIC ESNAULT's revision notes
he said in setMaxInactiveInterval() , -1 works like invalidate()
but the offical API said A negative time indicates the session should never timeout.
why??
|
 |
swapnl patil
Ranch Hand
Joined: Aug 13, 2007
Posts: 80
|
posted

0
|
setMaxInactiveInterval() takes time in second and web.xml we specify the time in minute.
then think on it. Read Head first for Servlet & JSP Session management chapter for more clarification .
|
 |
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire
Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing
|
SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
|
 |
Chrix Wu
Ranch Hand
Joined: Nov 15, 2009
Posts: 121
|
|
Lucas Smith wrote:Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire
Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing
what if i set the "time-out" in DD to the value of -1?
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
From the servlet spec about <session-timeout>
If the timeout is 0 or less, the container ensures the default behavior of sessions is never to time out.
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Chrix Wu
Ranch Hand
Joined: Nov 15, 2009
Posts: 121
|
|
Ankit Garg wrote:From the servlet spec about <session-timeout>
If the timeout is 0 or less, the container ensures the default behavior of sessions is never to time out.
Thanks
|
 |
Lucas Smith
Ranch Hand
Joined: Apr 20, 2009
Posts: 804
|
|
It's misleading.
setMaxInactiveInterval(0) -> invalidate()
<session-timeout>0</session-timeout> -> never invalidate
|
 |
warunyou rattanabuangam
Greenhorn
Joined: Jul 20, 2011
Posts: 1
|
|
Lucas Smith wrote:Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire
Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing
thank you.
|
 |
Cristian Daniel Ortiz Cuellar
Ranch Hand
Joined: Feb 02, 2011
Posts: 81
|
|
warunyou rattanabuangam wrote:
Lucas Smith wrote:Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire
Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing
thank you.
if i make request.getSession(false).setMaxInactiveInterval(0); the session will never expire..
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1043
|
|
have a look at this thread for more about his subject.
Regards,
Frits
|
 |
 |
|
|
subject: setMaxInactiveInterval and <session-timeout> question
|
|
|