• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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

 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
B & D.


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

and

session.setMaxInactiveInterval(-1);

Thanks,
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chandra,

you are trapped.
trapCount = 1.

Anybody guys.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chandra,

you are trapped for <session-timeout> tag.

you can see specs sothat you will not forget.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!