Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on sessions and cookies

 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can anyone tell me on what would happen to the session object when
they have these following settings

1) session.setMaxInactiveInterval(-1)

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

3) <session-config>
<session-timeout>-1</session-timeout>
<session-config>

4)What is the value to be used for setMaxAge() on the cookie object
so that it can stay on the client forever ?

5) Though not related to sessions/cookies..I have read in some places
that the order of the elements appearing in DD has significance

What is this order and what would happen if those elements are not
specified in that order ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
About 1,2,3,4 you can search yourself in the API and spec. It's a good exercice.
Concerning 5, it mays influence a few things. For example, the servlets with a <load-at-startup> set the the same number will be loaded in the order they have been defined in web.xml. (But I think it depends on the container)
The way listeners and filters are loaded is also related to the order.
 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satou ,
But my doubt on the cookies question still stands.
In the spec , for the setMaxAge(int expiry) function , it is specified
that
0 - cookie is deleted
<0 - cookie not persisted
>0 - cookie stays for so many seconds on the client.

But is it possible for the cookie to stay forever(i.e. remain active forever) on the client ?? If so what is the value to be specified ?

{There is a instance in HFSJ where it is mentioned that cookies can be
made to stay active forever on the client )
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about staying forever, but setMaxAge takes an integer, which should be enough to make it persistent for many years

If you want to keep some information forever, I think you should use something different. Like a DB.
[ January 26, 2006: Message edited by: Satou kurinosuke ]
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If you want to keep some information forever, I think you should use something different. Like a DB.


I didn't get you here. He is looking for storing the information on the client(browser) for ever and sending them back to the server with each request. In what way DB pictures here.
 
mayank jamindar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear muthu kumaran,

1)Session will Never expire.
2)Session expires as soon as created, practically session can not be created.
3) Session will Never expire.
4) Anything < 0, it will make your cookie never to destroy.
5) IF you change the order of Listners, filters, Servlets: it affects the Order of Instantiation, or Call.BUT
IF you at random shuffle any element with some different element, say error-page put before servlet element, your app. Sever will complain at startup, that the file is wrong, as its checked against DTD.
I think that answers you.
Do reply back,
Mayank
 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mayank,
Thanks for u'r answers.
For the 4th question on cookies," Anything < 0, it will make your cookie never to destroy" is not true coz the spec says if the setMaxAge() has a negative value, then the cookie will not be persisted and would be deleted
when the browser exits !!
 
Jay Tse
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mayank,

Also answer (3) is not correct.

If the <session-timeout> is set to "0" or "-1" in the DD, the session will never expire.

In the case of a servlet, setMaxInactiveInterval has to be set to "-1" only in order for the session to not expire. Setting it to "0" will expire the session immediately.

The DD and servlet are not consistent when it comes to setting the timeout of the session.

I learned this by answering one of the coffee cram exams in HFSJ.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic