aspose file tools*
The moose likes JSP and the fly likes jsp Sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp Sessions" Watch "jsp Sessions" New topic
Author

jsp Sessions

bruno martins
Greenhorn

Joined: Oct 28, 2003
Posts: 8
hi, i need help this is my code :
package com.stardeveloper.web.listener;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;
public class SessionCounter implements HttpSessionListener {
private static int activeSessions = 0;
public SessionCounter(){
}
public void sessionCreated(HttpSessionEvent se) {
activeSessions++;
}
public void sessionDestroyed(HttpSessionEvent se) {
if(activeSessions > 0)
activeSessions--;
}
public static int getActiveSessions() {
return activeSessions;
}
public void setActiveSessions() {
activeSessions--;
}

............
<%-- Sessions.jsp --%>
<%@ page import="com.stardeveloper.web.listener.SessionCounter" %>

<html>
<head>
<title>Active Sessions</title>
</head>
<body>
<p align="center">
<%HSListenerImpl act =new HSListenerImpl();%>

Active Sessions : <%=SessionCounter.getActiveSessions() %>


</p>
</body>
</html>
when i close the browser the session must call the metod sessionDestroyed()
but it not heappen var activeSessions not decrement(--)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61190
    
  66

There is no way to determinstically get notified when the browser is being closed. And you most certainly will not be able to make any server-side requests during the process. You will need to rely upon session timeout to know when the browser has gone away.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp Sessions