Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Session Timeout

 
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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • 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 ]
 
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.
 
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.
 
Author
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.
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic