| To: | users@xxxxxxxxxx |
|---|---|
| Subject: | how to test if a session is valid |
| From: | "radha ganapathy" <radha_ganapathy@xxxxxxxxxxx> |
| Date: | Wed, 08 Dec 2004 18:05:28 -0500 |
| Bcc: | |
| Delivered-to: | mailing list users@cinjug.org |
| Mailing-list: | contact users-help@cinjug.org; run by ezmlm |
|
Hi, I have an application deployed as ear file on weblogic6.1. The app has a class implementing HttpSessionAttributesListener. On successful login, I use setMaxInactiveInterval to set the timeout to 5 minutes. I use setAttribute to put the user id in the session with a tag of 'userid'. In the doPost() of all my servlets, I have the following code to check if session is valid. but even if i leave my session inactive for more than 5 minutes, this function returns true because the attributer 'userid' is still there. What is wrong in this method? protected boolean isSessionValid(HttpServletRequest req) { HttpSession oSession = req.getSession(); System.out.println("oSession.getMaxInactiveInterval() : " + oSession.getMaxInactiveInterval()); System.out.println("oSession.getLastAccessedTime() : " + oSession.getLastAccessedTime()); String strUserID = (String)oSession.getAttribute("userid"); System.out.println("oSession.getAttribute(\"userid\"): " + strUserID); if ( (strUserID == null) || (strUserID.length() == 0) ) { return false; } else { return true; } }
thanx, radha. |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | RE: [cinjug-users] Problem with html:link action= in WSAD 5.1, Brian K Bonner |
|---|---|
| Next by Date: | RE: [cinjug-users] Problem with html:link action= in WSAD 5.1, steve . gutter |
| Previous by Thread: | RE: [cinjug-users] Problem with html:link action= in WSAD 5.1, Hill, Richard |
| Next by Thread: | Re: [cinjug-users] how to test if a session is valid, Jason Kretzer |
| Indexes: | [Date] [Thread] [Top] [All Lists] |