You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/05/23 22:58:16 UTC
DO NOT REPLY [Bug 9367] New: -
HttpSessionBindingEvent not thrown for HttpSessionBindingListener objects when session expires
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9367>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9367
HttpSessionBindingEvent not thrown for HttpSessionBindingListener objects when session expires
Summary: HttpSessionBindingEvent not thrown for
HttpSessionBindingListener objects when session expires
Product: Tomcat 3
Version: 3.2.3 Final
Platform: HP
OS/Version: HP-UX
Status: NEW
Severity: Major
Priority: Other
Component: Servlet
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: saleems@dunnsolutions.com
This was reported by a user for TC 3.3. I have found it on 3.2.3 on HPUX as
well. The attached code works perfectly on TC 3.2.3 on Win NT 4 SP 6. Fails
always (i.e. HttpSessionBindingListener objects never get an unbound event)
when sessions expire on HPUX.
The following two JSP's demonstrate the bug. Install them in any web-
application. Open Monitor.jsp in a browser (it refreshes every 5 secs). Open
SessionTest.jsp in another (Monitor should now show the new session) and then
close the "SessionTest" browser window. After "session-timeout" minutes, the
row should vanish in the "Monitor" browser. It does on Windows. It does not on
HPUX.
Thank you.
----------- Begin Monitor.jsp --------------------------
<%@ page import="java.util.Map, java.util.Iterator" %>
<html><head>
<title>Test Monitor</title>
<META http-equiv="Refresh" content="5">
</head>
<body>
<h1>Monitor</h1>
Current time is <%= new java.util.Date().toString() %>
<h2>Bound objects</h2>
<table border = "1">
<tr><th>Session ID</th><th>Object Info</th></tr>
<%
ServletContext context = this.getServletConfig().getServletContext();
Map map = (Map)context.getAttribute("VALID_SESSIONS");
if (map != null) {
for (Iterator iter = map.keySet().iterator(); iter.hasNext() ; ) {
Object key = iter.next();
Object val = map.get(key);
%>
<tr><td><%= key %></td><td><%= val %></td></tr>
<%
}
}
%>
</table>
</body>
----------- End Monitor.jsp --------------------------
----------- Begin SessionTest.jsp --------------------------
<%@ page import="java.util.Map, java.util.Date, java.util.Hashtable,
java.util.Iterator" %>
<html>
<head><title>Session Test</title></head>
<body>
<h1>Session Test</h1>
<%!
class SessionSquatter implements HttpSessionBindingListener {
private Date myDate;
private String myId;
SessionSquatter(String id) {
this.myDate = new Date();
this.myId = id;
}
public String toString() {
return "Squatter for session " + myId + " created at " + myDate.toString();
}
public void valueBound(HttpSessionBindingEvent event) {
bound(myId, this);
}
public void valueUnbound(HttpSessionBindingEvent event) {
unbound(myId);
}
}
%>
<%!
private void bound(String id, SessionSquatter squatter) {
ServletContext context = this.getServletConfig().getServletContext();
Map map = (Map)context.getAttribute("VALID_SESSIONS");
if (map == null) {
map = new Hashtable(10);
context.setAttribute("VALID_SESSIONS", map);
}
map.put(id, squatter);
System.out.println("+++ Bound! " + toString());
}
%>
<%!
private void unbound(String id) {
ServletContext context = this.getServletConfig().getServletContext();
Map map = (Map)context.getAttribute("VALID_SESSIONS");
if (map == null) { return; }
map.remove(id);
System.out.println("--- Unbound! " + toString());
}
%>
<%
ServletContext context = this.getServletConfig().getServletContext();
Map map = (Map)context.getAttribute("VALID_SESSIONS");
if (map == null) {
map = new Hashtable(10);
context.setAttribute("VALID_SESSIONS", map);
}
String sessionId = session.getId();
SessionSquatter squatter = new SessionSquatter(sessionId);
session.setAttribute("SQUATTER", squatter);
%>
Session <%= sessionId %> contains <%= squatter.toString() %>.
<br/><a href="javascript:window.close()">Close this window.</a><br/>
</body>
</html>
----------- End SessionTest.jsp --------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>