• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Timeout

 
Reshma Shanbhag
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

HFSJ SessionManagement chapter mentions, the session timeout period set to 0 programatically, session immidiately invalidates.

In the below question from j2eecertificate.com, as per the above answer should have been 1, but the answer is 3, ???



<session-config>
<session-timeout>0</session-timeout></session-config>


Given the following extract from a web application's deployment descriptor, what is the default duration that the servlet container will keep a session from being invalidated between client accesses.



1. 0 minutes.



2. 0 seconds.



3. The session is never invalidated.



4. 30 minutes.



5. The default session timeout interval is container specific




[ May 15, 2006: Message edited by: Reshma Pai ]

[ May 15, 2006: Message edited by: Reshma Pai ]

[ May 15, 2006: Message edited by: Reshma Pai ]
[ May 15, 2006: Message edited by: Reshma Pai ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Programmatically means calling setMaxInactiveInterval() from your servlet. (=programmatically setting the seesion timeout)
setMaxInactiveInterval(0) will invalidate the session immediately, as stated in your book.

The mock question is about session-timeout in web.xml (=declaratively setting the session timeout)
The session will never be invalidated if it is set to 0.

This is a common pitfall at the exam, be careful.
[ May 15, 2006: Message edited by: Satou kurinosuke ]
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The session will never be invalidated if it is set to 0.

PLUS
A negative value in <session-timeout> tag will also keep the session alive for ever.
 
Yogesh Hingmire
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Any idea what the setMaxInactiveInterval(-1) will result in ?

Thanks,
Yogesh.
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J2EE API documentation tells all:
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.

Of course, a zero time indicates that 0 seconds should be taken before invalidating - i.e. invalidating immediately.
 
Reshma Shanbhag
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers thanks for the help. I am clear about the difference after reading your posts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic