This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes when session time out doesn't occur (automatically) ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "when session time out doesn Watch "when session time out doesn New topic
Author

when session time out doesn't occur (automatically) ?

Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Ranchers,

when session time out doesn't occur (automatically) ?
Take this question:

A. <session-timeout>0</session-timeout>
B. <session-timeout>-1<session-timeout>
C. session.setMaxInactiveInterval(0);
D. session.setMaxInactiveInterval(-1);
E. ALL

Good trap.
try to get out of it.
[ August 16, 2007: Message edited by: Srinivasan thoyyeti ]

Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
B & D.


<session-timeout>-1</session-timeout>

and

session.setMaxInactiveInterval(-1);

Thanks,


cmbhatt
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Chandra,

you are trapped.
trapCount = 1.

Anybody guys.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
From specification:

setMaxInactiveInterval()

By definition, if the timeout period for a session is set to -1, 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.


"Automatically" is the trap! May be!

Thanks,
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Chandra,

you are trapped for <session-timeout> tag.

you can see specs sothat you will not forget.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Srinivasan,

Could you please specify what specification says regarding <session-timeout>
and negative value to it.

I understand it takes value in minutes unlike setMaxInactiveInterval()
that takes in seconds.

Is there mention of negative value and <session-timeout> element.

I don't find any!

Thanks,
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
<xsd:element name="session-timeout"
type="j2ee:xsdIntegerType"
minOccurs="0">
<xsd:annotation>
<xsd ocumentation>
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.
</xsd ocumentation>

</xsd:annotation>
</xsd:element>

So its better to read the documentation given in XSD, for elements in exam scope.we will never miss the target again.

[ August 16, 2007: Message edited by: Srinivasan thoyyeti ]
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hey Srinivasan,

I didn't get this:


If the timeout is 0 or less, the container ensures
the default behaviour of sessions is never to time
out.


Doesn't that mean what I expected?
Value 0 or less, default behavior to never timeout.
I don't get anywhere in any available book that says
what you are saying.

Kindly focus some more light there!

Thanks,
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Chandra,

Come on yaaar.

in case of <session-timeout> tag set to <=0 then session will never expire.
in case of setMaxInactiveInterval (<0) can only make it never expire.

So answer should be A,B,D.
Got me ?
[ August 16, 2007: Message edited by: Srinivasan thoyyeti ]
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
But value 0 means, invalidate immediately.

Where did you get that extract from?
The specification copy I have, there is nothing like what you said.

Anyways!!!
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Chandra,

Here there are two cases.

you are talking about programmatic session time out.
i.e.,
setMaxInactiveInterval(x); where x < 0. will make the session never expire.

I think you know x < 0.

Here is the API

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

[ August 16, 2007: Message edited by: Srinivasan thoyyeti ]
Promod kumar
Ranch Hand

Joined: Jun 26, 2006
Posts: 90
Here is a link that might help. I can't keep it straight either.

http://www.coderanch.com/t/174085/java-Web-Component-SCWCD/certification/session-never-dies
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Pramod,
Posted by Pramod :
Here is a link that might help.I can't keep it straight either.


What you find in this thread missing.
Which forced you to refer other link.
[ August 16, 2007: Message edited by: Srinivasan thoyyeti ]
Promod kumar
Ranch Hand

Joined: Jun 26, 2006
Posts: 90
I am not saying that something is missing in this thread. I perfectly understand the explanation, I just can't seem to retain it very well.
As for the link, I just do a search first if I have a question. because most of the questions I have have already been discussed. It is just a matter of habit. The link was supposed to add more information.
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Your intention is good.
I know people refer to other threads when the information lacks or not clear.

I have posted specification for <session-timeout>
and
API for setMaxInactiveInterval()

After reading them also "you can't keep it stright" means
where is the fault ?
 
Don't get me started about those stupid light bulbs.
 
subject: when session time out doesn't occur (automatically) ?