This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes sessions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "sessions?" Watch "sessions?" New topic
Author

sessions?

Preethi Suryam
Ranch Hand

Joined: Nov 17, 2000
Posts: 92
Hi!
when will a session gets invalidated.when i set the session to setMaxInactiveInterval(-1) the session should not timeout.but i am getting as "session invalidated."can some one throw some light on this.
Regards!
Preethi.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

Hmm in the API both setMaxInactiveInterval() and getMaxInactiveInterval() say it should not timeout.


SCJP
Visit my download page
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
How did you test? I tested with -1 argument and didn't get any such errors. What I did was, after a user successfully logd into web appln I usually create a session with HttpSession sessn = request.getSession(true) . Now I added one more line as sessn.setMaxInactiveInterval(-1); statement and the web appln behaves as before.
But if you purposly make sessn.invalidate(), the session WILL get invalidated.
How did you test your case?
regds
maha anna
Preethi Suryam
Ranch Hand

Joined: Nov 17, 2000
Posts: 92
Hi Maha Anna!
I am testing it with HttpSessionBindingListner valueunbound().I have set session.putValue() and then setMaxInactiveInterval(-1).
In the next jsp page i am getting the value and the value comes out to be null.I am using JRun and Beans.
Thanks and Regards!
Preethi
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Preethi,
Did you comment the 'setMaxInactiveIntervel(-1);' line and check? Just to fine out where the problem is.
Try to comment and uncomment 'setMaxInactiveIntervel(-1);' and 'BindingLinstener' and see if we could pinpoint the problem.
regds
maha anna
Preethi Suryam
Ranch Hand

Joined: Nov 17, 2000
Posts: 92
Hi Mana Anna!
I tried out setMaxInactiveInterval(10*60*60) it is working fine.JRun is not accepting -1.
-1 is working fine with java web server.And while configuring JRun it is very well given that we can give -1 for a session not to time out.could u tell me the reason? Anyway my module is working fine now.Thanx a lot for ur concern and help.
Regards!
Preethi.
Heather Wu
Greenhorn

Joined: Apr 23, 2001
Posts: 3
Hi,
Do I need to do the setMaxinactiveInterval in all the pages or the SignIn page(the SignIn page is where the user sign in), all I want the session to remember is the signid and password.
But even I specified setMaIactiveInterval(3600000)in the SignIn page and I still getting time out.
please advise.
Thanks
sreekanth nair
Greenhorn

Joined: Mar 12, 2007
Posts: 20
setMaxInactiveInterval(int interval)

Set a session timeout interval, in seconds, as an integer, overriding any default in the servlet container or set through the web.xml <session-timeout> element. A negative value indicates no timeout. A value of 0 results in an immediate timeout


If you want to time out otherwise use session.invalidate()

You can check with isNew() to identify the session or comparing id's by getId()
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sessions?