Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session timeout

 
vijaya saradhi
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi ,

can any one please clear my doubt about session timeout.In HFSJ it was mentioned like this, if we give -1 as session timeout value the session will never expire.Is it true.
I am doubtful about it.If any one knows please share your knowledge.


adv thanks, vijayasaradhi duggirala
 
Zaheer A Baloch
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes! It is true. Please do not doubt what the HFSJ book has to say. Its a religous book for SCWCD and it contains words of truth. Just kidding, its always good to get doubts cleared.

There are two ways we can make sure the session never expires.
Through web.xml:



Through HttpSession interface method in a servlet:


Any negative value means that this session shall never expire, unless you forcefully invalidate it using HttpSession.invalidate() method.

Hope this helps.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

May be this will help you

http://nishanpatel.wordpress.com/2009/04/30/deploymentdescriptor/

 
Chamara Jayaweera
Ranch Hand
Posts: 66
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

No doubts, HFSJ is correct and It happeans as it is.If you still have doubts then develop a small app and test it practically.Then you will never forget
 
Cristian Daniel Ortiz Cuellar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chamara Jayaweera wrote:Hi,

No doubts, HFSJ is correct and It happeans as it is.If you still have doubts then develop a small app and test it practically.Then you will never forget


hey guys if i make make either in DD or in code -1 Or any negative number the session will never expire??

if i put on the DD a value of 0. what would happen? the session is invalidate inmediataly???

sorry by my poor english.

thanks..
 
mohana krishna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Session-timeout in DD is 0 then session will never expire
 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mohana krishna wrote:If Session-timeout in DD is 0 then session will never expire

Hmm interesting, the 0 value's behavior is not specified in JavaEE 5 documentation but it is in JavaEE 6 documentation. I'll have to check the servlet specification 2.4 if 0 timeout is specified in it but if its not then it will not be asked in SCWCD 5 exam...
 
mohana krishna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

As per servlet-2_4-fr-spec.pdf file. PATH : http://download.oracle.com/otndocs/jcp/servlet-2.4-fr-spec-oth-JSpec/

"The session-timeout element defines the default
session timeout interval for all sessions created
in this web application. The specified timeout
must be expressed in a whole number of minutes.
If the timeout is 0 or less, the container ensures
the default behaviour of sessions is never to time
out. If this element is not specified, the container
must set its default timeout period."

So If Session-timeout in DD is 0 then session will never expire.
 
Jelo Nehuptra
Ranch Hand
Posts: 36
Java jQuery Netbeans IDE
 
Jelo Nehuptra
Ranch Hand
Posts: 36
Java jQuery Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you insist:

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


EE6
"Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.
An interval value of zero or less indicates that the session should never timeout."
 
Sharad Kharya
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can be set-up in the deployment descriptor:
--- minutes (<= 0, session should never expire)
- Individual session, setMaxInactiveInterval(int seconds) --- seconds (<0 never expire, 0 expire immediately).

If you define values in DD and in code then the value specified in code will override the session timeout for that session.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic