J
juppie
Hello all,
I have the following scenario in my Tapestry app.
1) User clicks logout - application servlet invokes proper listener
method which obtains session from HttpServletRequest.getSession(false)
and invalidates it. (HttpSession.invalidate())
2) After that, in the same request another method is invoked which
excecution depends on whether user session exists and is valid. I have
no knowledge that logOut method was invoked earlier.
So this method once again queries HttpServletRequest.getSession(false)
for session and it gets one (??), the one that was just invalidated.
I expected the HttpServletRequest to return null, as the session is
already invalid.
Now - how can I check if this session is still valid? I cannot find any
isValid() method on session, neither I want to keep track of created
sessions through HttpSessionListener - I just need a simple answer from
servlet container - IS THIS SESSION VALID?
This basically boils down to separate invocations of methods:
public logOut(HttpServletRequest request)
{
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
}
}
public doSomething(HttpServletRequest request)
{
HttpSession session = request.getSession(false);
//check if the session exists and is valid
if (????) {
do sth with valid session
}
}
Thanks in advance for any suggestions,
Bernard
I have the following scenario in my Tapestry app.
1) User clicks logout - application servlet invokes proper listener
method which obtains session from HttpServletRequest.getSession(false)
and invalidates it. (HttpSession.invalidate())
2) After that, in the same request another method is invoked which
excecution depends on whether user session exists and is valid. I have
no knowledge that logOut method was invoked earlier.
So this method once again queries HttpServletRequest.getSession(false)
for session and it gets one (??), the one that was just invalidated.
I expected the HttpServletRequest to return null, as the session is
already invalid.
Now - how can I check if this session is still valid? I cannot find any
isValid() method on session, neither I want to keep track of created
sessions through HttpSessionListener - I just need a simple answer from
servlet container - IS THIS SESSION VALID?
This basically boils down to separate invocations of methods:
public logOut(HttpServletRequest request)
{
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
}
}
public doSomething(HttpServletRequest request)
{
HttpSession session = request.getSession(false);
//check if the session exists and is valid
if (????) {
do sth with valid session
}
}
Thanks in advance for any suggestions,
Bernard