I have a session time out configured in the web.xml.In my filter I use request.getSession(false).Then I check the value in my session object.But even after the session has expired my session object does not get a null value.
Can you tell me how to check if my session has expired?
by using getLastAccessedTime() we get some time in milliseconds
and if it exceeds the time you have mentioned(<session-timeout> in web.xml(that represents hours) call invalidate() so that the session will be destroyed.
hope this works.
SCJP 1.4 & 1.5, SCWCD 1.5. Learn and Let Learn.
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
posted
0
I am sure you session is not expired.You can try setting a session listner for tracking whether session has really expired or not.
Originally posted by Jetendra Ivaturi: (<session-timeout> in web.xml(that represents hours)
The <session-config> <session-timeout>?</session-timeout> </session-config>
Is actually minutes.
SCJP, SCWCD
Soma Kora
Greenhorn
Joined: Apr 10, 2007
Posts: 6
posted
0
Hi,
Here I am facing one problem. I am checking session validity
1: if (! request.isRequestedSessionIdValid()) return mapping.findForward("invalidSession");
2: user = (User)request.getSession().getAttribute("user"); if (user == null){ // throw exception if it is null; throw new ApplicationException("User session unavailable"); }
Problem: In line i get true for request.isRequestedSessionIdValid() but when i am trying to get value from session(ie line 2) it is giving "User session unavailable")?
Can you pls suggest where went wrong?
Thanks.
Jilani Jidni
Greenhorn
Joined: Feb 06, 2007
Posts: 8
posted
0
Hello kora,
You are checked for session availability and session is available. But you try to get session with attribute "user". Please check session with user attribute are available in your session. otherwise check whether you set your session.