• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Enthuware Question

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which of the following situations will a session be definitely invalidated?(You have to select 3 option)

A:The container is shutdown and brought up again.
B:No request comes from the client for more than "session timeout" period.
C:A servlet explicitly calls invalidate() on a session object.
D:If the session time out is set to 0 using setMaxInactiveInterval() method.

The answer is BC and D

My Doubt in option D because API specifies that

"A return value of zero or less indicates that the session will never timeout. "
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3714
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the JavaDoc API description :
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.
 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This API Specifies "A return value of zero or less indicates that the session will never timeout. "
HttpSession

http://docs.oracle.com/javaee/6/api/

 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3714
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems Oracle's API description for this method is not consistent. This needs to be investigated further. But for now, I would go with the link that you are using. That seems to be more authentic. So this option should be marked incorrect.

HTH,
Paul.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2345
90
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul and Ashok,

We had this discussion earlier, have a look here for the explanation:
Session Timeout

Regards,
Frits
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3714
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just checked Servlet 3.0 Specification (Final) and it states:

Section 7.5 Session Timeouts

The default time out period for sessions is defined by the servlet container and can
be obtained via the getMaxInactiveInterval method of the HttpSession interface.
This time out can be changed by the Developer using the setMaxInactiveInterval
method of the HttpSession interface. The time out periods used by these methods
are defined in seconds. By definition, if the time out period for a session is set to -1,
the session will never expire.



So the answer given in our s/w is correct.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2345
90
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm interesting, it seems they are in the process of changing this, because in the Maintenance Release of the Servlet 3.0 specs Version 3.0 Rev a (6 February 2011),
this is written:

7.5 Session Timeouts
The default time out period for sessions is defined by the servlet container and can
be obtained via the getMaxInactiveInterval method of the HttpSession interface.
This time out can be changed by the Developer using the setMaxInactiveInterval
method of the HttpSession interface. The time out periods used by these methods
are defined in seconds. By definition, if the time out period for a session is set to 0 or
lesser value, the session will never expire.
The session invalidation will not take
effect until all servlets using that session have exited the service method. Once the
session invalidation is initiated, a new request must not be able to see that session.

Regards,
Frits
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3714
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frits, You are right. The same statement exists in Servlet 3.1 Early Draft ( June 2012 ) as well. So it seems they have made up their mind now. We will update the question accordingly.

thank you,
Paul.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic