Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

maintaining session

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to maintain session for 1 day.How can i do this?
my code to maintain session is:


Am i correct here?whether i have to mention any time here?

Thanks
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the setMaxInactiveInterval(int interval) method of the HttpSession interface.

The following link will quide you

HttpSession
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The session will timeout based on the session timeout element in web.xml or the setMaxInactiveInterval() method can be used to control this time. You can adjust this based on the solution need - declarative or programmatic
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.But i have to mention the time in milliseconds?(ie)if i need to maintain the session for 24 hours means should i give like this?
 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi preethi Ayyappan ,

We can maintain sessions time outs in two ways say thru web.xml or
thru program i.e in your servlet.

Session settings at web.xml effects thru out web application and here we need to set time in minutes.

Where as session.setMaxInactiveInterval() takes in secs where as applicable for that single servlet only.
 
Karthikeyan Ramaswamy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, you can give like session.setMaxInactiveInterval(86400000);

and also you can configure in web.xml. like below



In web.xml we can specify in minutes only
In setMaxInactiveInterval we can specify milliseconds only
[ May 19, 2008: Message edited by: Karthikeyan R ]
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.whether i have to mention the set max interval in each servlet wherever i have maintained the session or only in login servlet?
 
Karthikeyan Ramaswamy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you set session-timeout in web.xml it effects whole web application,
if you set in setMaxInactiveInterval it effect only that particular servlet,
so using session-timeout tag in web.xml is good coding practice.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.i will do that
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic