Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Keeping Session Alive

 
Santosh Raveendran
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can anyone please confirm whether a life long session can be achieved

in the below cases

1)In DD specify a value of -1 for <session-timeout> element

2)programatically set session.setMaxInactiveInterval(-1)

3)In DD specify a value of 0 for <session-timeout> element

i Read the third from a scwcd prepration kit and confused about it ,

please advice

Thanks
santhosh
 
Devasani Naresh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
both cases work in the same way... I think.
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Santosh,

all the three possibilities that you are listed up are correct. The <session-timeout>-Tag and the setMaxInActiveInterval have the same intention, but there are a few differents. One is the meaning of the parameter 0 which has a different behaviour for both possibilities. The other fact is unit, which is for the DD-tag minutes, and for the set-Method second.
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the 3 imply that session will never expire..
But 1 and 3 apply to all the sessions while the 2nd applies to a particular session that is programmatic
 
Salim Khatib
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you programatically set session.setMaxInactiveInterval(0)
it is equivalent to calling session.inValidate() where the session get invalid immediately
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Salim,

it is equivalent.
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are many wrong answers on this post ... it would be better if we double check for the answer before posting it, from the Java specs :


setMaxInactiveInterval

public void setMaxInactiveInterval(int interval)

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.

Parameters:
interval - An integer specifying the number of seconds


*Conclusion: for the method setMaxInactiveInterval(x) it means
1) x > 0 ----> you set the idle time in seconds that will invalidate that specific session object
2) x < 0 ----> that specific session object will never expire, ofcourse unless you shut down your web container
3) x = 0 ----> it will have the same meaning as calling sessionObject.invalidate()



while for the <session-timeout> tag in the web.xml file describes the session timeout in minutes, if its 0 or negative means never timeout, and it defaults to 30
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Omar,

thanks for your post. I've read it twice but I'm still stumbling over your sentence

there are many wrong answers on this post ...


I'don't see any wrong answers in this thread. Can you please explain, where you 've found wrong answers ?

 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops I apologize actually it was my fault i read the question wrong i mistaken the value of the "0" for the DD i thought it was for the setMaxInactiveInterval method, which makes all the answers 100% correct.

I apologize again for this mistake, may be its better that i delete my previous post to avoid confusion for users reading the post what do you think Christian ?

really sorry for this mistake.

(peace)
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Omar,

this is not a problem. You 've try to help us in finding right answers for the questions, and I doesn't matter that the content of your first post was wrong. I think reading a question wrong has happend to everyone of us.

I hope that you continue find answers on questions which are posted on this forum and helping so other people.
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See <session-timeout> element in the D.D if 0 or -1... that means all the seesions in that application WILL NEVER EXPIRE...
Also if you have to set some session timeout time Programmaticaly them for that particular session session.setMaxInactiveInterval(-1) WILL NEVER EXPIRE...

session.setMaxInactiveInterval(0) this WILL IMMEDIATELY EXPIRE...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic