This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

setMaxInactiveInterval and <session-timeout> question  RSS feed

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are the following four the same ?




 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire

Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing
 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's misleading.
setMaxInactiveInterval(0) -> invalidate()
<session-timeout>0</session-timeout> -> never invalidate
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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..

 
Creator of Enthuware JWS+ V6
Posts: 3273
296
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have a look at this thread for more about his subject.

Regards,
Frits
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!